diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-19 15:06:45 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-19 15:11:37 +0300 |
commit | 7cf7afb7815b2db2c923dd8d2de213c13cba4807 (patch) | |
tree | 652356380fe9b26d9b3571670e5300589e3928b9 /src/store/conversationSharedItemsStore.js | |
parent | 9b9d30b9f7ef266af317c17ca33c157451027ba8 (diff) |
Fix store stuff
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src/store/conversationSharedItemsStore.js')
-rw-r--r-- | src/store/conversationSharedItemsStore.js | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/store/conversationSharedItemsStore.js b/src/store/conversationSharedItemsStore.js index b58de46fc..9242dd0c8 100644 --- a/src/store/conversationSharedItemsStore.js +++ b/src/store/conversationSharedItemsStore.js @@ -113,16 +113,32 @@ export const mutations = { } const actions = { - async getSharedItems({ commit }, { token, type, lastKnownMessageId, limit }) { + async getSharedItems({ commit, state }, { token, type }) { + if (!state.sharedItemsByConversationAndType[token] + || !state.sharedItemsByConversationAndType[token][type]) { + console.error('Missing overview for shared items in ', token) + return false + } + + const limit = 100 + const lastKnownMessageId = Math.min.apply(Math, Object.keys(state.sharedItemsByConversationAndType[token][type])) try { const response = await getSharedItems(token, type, lastKnownMessageId, limit) + const messages = response.data.ocs.data + const hasMore = messages.length >= limit + // loop over the response elements and add them to the store - for (const sharedItem in response) { - commit('addSharedItem', sharedItem) + for (const message in messages) { + commit('addSharedItemMessage', { + token, + type, + message, + }) } - + return hasMore } catch (error) { - console.debug(error) + console.error(error) + return false } }, @@ -132,13 +148,13 @@ const actions = { } try { - const response = await getSharedItemsOverview(token, 10) + const response = await getSharedItemsOverview(token, 7) commit('addSharedItemsOverview', { token, data: response.data.ocs.data, }) } catch (error) { - console.debug(error) + console.error(error) } }, |