|
|
@ -20,20 +20,21 @@ const emptyTl = (userId = 0) => ({
|
|
|
|
flushMarker: 0
|
|
|
|
flushMarker: 0
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emptyNotifications = () => ({
|
|
|
|
|
|
|
|
desktopNotificationSilence: true,
|
|
|
|
|
|
|
|
maxId: 0,
|
|
|
|
|
|
|
|
minId: Number.POSITIVE_INFINITY,
|
|
|
|
|
|
|
|
data: [],
|
|
|
|
|
|
|
|
idStore: {},
|
|
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
|
|
error: false
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
export const defaultState = () => ({
|
|
|
|
export const defaultState = () => ({
|
|
|
|
allStatuses: [],
|
|
|
|
allStatuses: [],
|
|
|
|
allStatusesObject: {},
|
|
|
|
allStatusesObject: {},
|
|
|
|
maxId: 0,
|
|
|
|
maxId: 0,
|
|
|
|
notifications: {
|
|
|
|
notifications: emptyNotifications(),
|
|
|
|
desktopNotificationSilence: true,
|
|
|
|
|
|
|
|
maxId: 0,
|
|
|
|
|
|
|
|
minId: Number.POSITIVE_INFINITY,
|
|
|
|
|
|
|
|
data: [],
|
|
|
|
|
|
|
|
idStore: {},
|
|
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
|
|
error: false,
|
|
|
|
|
|
|
|
fetcherId: null
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
favorites: new Set(),
|
|
|
|
favorites: new Set(),
|
|
|
|
error: false,
|
|
|
|
error: false,
|
|
|
|
timelines: {
|
|
|
|
timelines: {
|
|
|
@ -359,9 +360,6 @@ export const mutations = {
|
|
|
|
oldTimeline.visibleStatusesObject = {}
|
|
|
|
oldTimeline.visibleStatusesObject = {}
|
|
|
|
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
|
|
|
each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status })
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setNotificationFetcher (state, { fetcherId }) {
|
|
|
|
|
|
|
|
state.notifications.fetcherId = fetcherId
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
resetStatuses (state) {
|
|
|
|
resetStatuses (state) {
|
|
|
|
const emptyState = defaultState()
|
|
|
|
const emptyState = defaultState()
|
|
|
|
Object.entries(emptyState).forEach(([key, value]) => {
|
|
|
|
Object.entries(emptyState).forEach(([key, value]) => {
|
|
|
@ -371,6 +369,9 @@ export const mutations = {
|
|
|
|
clearTimeline (state, { timeline }) {
|
|
|
|
clearTimeline (state, { timeline }) {
|
|
|
|
state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
|
|
|
|
state.timelines[timeline] = emptyTl(state.timelines[timeline].userId)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
clearNotifications (state) {
|
|
|
|
|
|
|
|
state.notifications = emptyNotifications()
|
|
|
|
|
|
|
|
},
|
|
|
|
setFavorited (state, { status, value }) {
|
|
|
|
setFavorited (state, { status, value }) {
|
|
|
|
const newStatus = state.allStatusesObject[status.id]
|
|
|
|
const newStatus = state.allStatusesObject[status.id]
|
|
|
|
newStatus.favorited = value
|
|
|
|
newStatus.favorited = value
|
|
|
@ -454,12 +455,6 @@ const statuses = {
|
|
|
|
setNotificationsSilence ({ rootState, commit }, { value }) {
|
|
|
|
setNotificationsSilence ({ rootState, commit }, { value }) {
|
|
|
|
commit('setNotificationsSilence', { value })
|
|
|
|
commit('setNotificationsSilence', { value })
|
|
|
|
},
|
|
|
|
},
|
|
|
|
stopFetchingNotifications ({ rootState, commit }) {
|
|
|
|
|
|
|
|
if (rootState.statuses.notifications.fetcherId) {
|
|
|
|
|
|
|
|
window.clearInterval(rootState.statuses.notifications.fetcherId)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
commit('setNotificationFetcher', { fetcherId: null })
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteStatus ({ rootState, commit }, status) {
|
|
|
|
deleteStatus ({ rootState, commit }, status) {
|
|
|
|
commit('setDeleted', { status })
|
|
|
|
commit('setDeleted', { status })
|
|
|
|
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
|
|
|
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
|
|
|