mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Merge pull request #16543 from nextcloud/fix/noid/shared-items-store
fix: update shared items store correctly
This commit is contained in:
commit
0d08d99d27
2 changed files with 32 additions and 0 deletions
|
|
@ -1380,6 +1380,7 @@ const actions = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const chatExtrasStore = useChatExtrasStore()
|
const chatExtrasStore = useChatExtrasStore()
|
||||||
|
const sharedItemsStore = useSharedItemsStore()
|
||||||
const chatStore = useChatStore()
|
const chatStore = useChatStore()
|
||||||
const timestamp = convertToUnix(Date.now())
|
const timestamp = convertToUnix(Date.now())
|
||||||
|
|
||||||
|
|
@ -1390,8 +1391,11 @@ const actions = {
|
||||||
}
|
}
|
||||||
context.commit('deleteMessage', { token, id: message.id })
|
context.commit('deleteMessage', { token, id: message.id })
|
||||||
chatStore.removeMessagesFromChatBlocks(token, message.id)
|
chatStore.removeMessagesFromChatBlocks(token, message.id)
|
||||||
|
sharedItemsStore.deleteSharedItemFromMessage(token, message.id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sharedItemsStore.purgeExpiredSharedItems(token, timestamp)
|
||||||
},
|
},
|
||||||
|
|
||||||
async easeMessageList(context, { token }) {
|
async easeMessageList(context, { token }) {
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,33 @@ export const useSharedItemsStore = defineStore('sharedItems', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purge expired shared items from the store
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param timestamp
|
||||||
|
*/
|
||||||
|
function purgeExpiredSharedItems(token: string, timestamp: number) {
|
||||||
|
if (!sharedItemsPool[token]) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const type of Object.keys(sharedItemsPool[token])) {
|
||||||
|
for (const id of Object.keys(sharedItemsPool[token][type])) {
|
||||||
|
const message = sharedItemsPool[token][type][+id]
|
||||||
|
if (message.expirationTimestamp && message.expirationTimestamp < timestamp) {
|
||||||
|
delete sharedItemsPool[token][type][+id]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Object.keys(sharedItemsPool[token][type]).length === 0) {
|
||||||
|
delete sharedItemsPool[token][type]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Object.keys(sharedItemsPool[token]).length === 0) {
|
||||||
|
delete sharedItemsPool[token]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch shared items of a specific type for a conversation
|
* Fetch shared items of a specific type for a conversation
|
||||||
*
|
*
|
||||||
|
|
@ -206,6 +233,7 @@ export const useSharedItemsStore = defineStore('sharedItems', () => {
|
||||||
addSharedItemFromMessage,
|
addSharedItemFromMessage,
|
||||||
deleteSharedItemFromMessage,
|
deleteSharedItemFromMessage,
|
||||||
addSharedItemsFromMessages,
|
addSharedItemsFromMessages,
|
||||||
|
purgeExpiredSharedItems,
|
||||||
purgeSharedItemsStore,
|
purgeSharedItemsStore,
|
||||||
fetchSharedItems,
|
fetchSharedItems,
|
||||||
fetchSharedItemsOverview,
|
fetchSharedItemsOverview,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue