aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/chats.js1
-rw-r--r--src/modules/statuses.js14
-rw-r--r--src/modules/users.js38
3 files changed, 45 insertions, 8 deletions
diff --git a/src/modules/chats.js b/src/modules/chats.js
index f28c2603..0f1540db 100644
--- a/src/modules/chats.js
+++ b/src/modules/chats.js
@@ -65,6 +65,7 @@ const chats = {
const newChatMessageSideEffects = (chat) => {
maybeShowChatNotification(store, chat)
}
+ commit('addNewUsers', chats.map(k => k.account).filter(k => k))
commit('addNewChats', { dispatch, chats, rootGetters, newChatMessageSideEffects })
},
updateChat ({ commit }, { chat }) {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 77dd7e1c..93a4a957 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -615,9 +615,19 @@ const statuses = {
fetchStatusHistory ({ rootState, dispatch }, status) {
return apiService.fetchStatusHistory({ status })
},
- deleteStatus ({ rootState, commit }, status) {
- commit('setDeleted', { status })
+ deleteStatus ({ rootState, commit, dispatch }, status) {
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ .then((_) => {
+ commit('setDeleted', { status })
+ })
+ .catch((e) => {
+ dispatch('pushGlobalNotice', {
+ level: 'error',
+ messageKey: 'status.delete_error',
+ messageArgs: [e.message],
+ timeout: 5000
+ })
+ })
},
deleteStatusById ({ rootState, commit }, id) {
const status = rootState.statuses.allStatusesObject[id]
diff --git a/src/modules/users.js b/src/modules/users.js
index a23f6d7d..e976d875 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -195,9 +195,15 @@ export const mutations = {
state.currentUser.blockIds.push(blockId)
}
},
+ setBlockIdsMaxId (state, blockIdsMaxId) {
+ state.currentUser.blockIdsMaxId = blockIdsMaxId
+ },
saveMuteIds (state, muteIds) {
state.currentUser.muteIds = muteIds
},
+ setMuteIdsMaxId (state, muteIdsMaxId) {
+ state.currentUser.muteIdsMaxId = muteIdsMaxId
+ },
addMuteId (state, muteId) {
if (state.currentUser.muteIds.indexOf(muteId) === -1) {
state.currentUser.muteIds.push(muteId)
@@ -320,10 +326,20 @@ const users = {
.then((inLists) => store.commit('updateUserInLists', { id, inLists }))
}
},
- fetchBlocks (store) {
- return store.rootState.api.backendInteractor.fetchBlocks()
+ fetchBlocks (store, args) {
+ const { reset } = args || {}
+
+ const maxId = store.state.currentUser.blockIdsMaxId
+ return store.rootState.api.backendInteractor.fetchBlocks({ maxId })
.then((blocks) => {
- store.commit('saveBlockIds', map(blocks, 'id'))
+ if (reset) {
+ store.commit('saveBlockIds', map(blocks, 'id'))
+ } else {
+ map(blocks, 'id').map(id => store.commit('addBlockId', id))
+ }
+ if (blocks.length) {
+ store.commit('setBlockIdsMaxId', last(blocks).id)
+ }
store.commit('addNewUsers', blocks)
return blocks
})
@@ -346,10 +362,20 @@ const users = {
editUserNote (store, args) {
return editUserNote(store, args)
},
- fetchMutes (store) {
- return store.rootState.api.backendInteractor.fetchMutes()
+ fetchMutes (store, args) {
+ const { reset } = args || {}
+
+ const maxId = store.state.currentUser.muteIdsMaxId
+ return store.rootState.api.backendInteractor.fetchMutes({ maxId })
.then((mutes) => {
- store.commit('saveMuteIds', map(mutes, 'id'))
+ if (reset) {
+ store.commit('saveMuteIds', map(mutes, 'id'))
+ } else {
+ map(mutes, 'id').map(id => store.commit('addMuteId', id))
+ }
+ if (mutes.length) {
+ store.commit('setMuteIdsMaxId', last(mutes).id)
+ }
store.commit('addNewUsers', mutes)
return mutes
})