diff options
| author | Henry Jameson <me@hjkos.com> | 2023-04-12 23:31:11 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2023-04-12 23:31:11 +0300 |
| commit | 3e1aeb6d2c9b540271bd0d7890ab424cb27422ae (patch) | |
| tree | cc8a9c3a63c92bd1a55b849c5380f52e0a58c9a0 /src/modules/users.js | |
| parent | 9e5c7313c64c9f9eeff7184f5f474cc055d80715 (diff) | |
| parent | bc830cd03365387b30a2900d133155bf3858f1fe (diff) | |
Merge remote-tracking branch 'origin/develop' into improve_settings_reusability
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 38 |
1 files changed, 32 insertions, 6 deletions
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 }) |
