mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-17 21:12:20 +01:00
fix(ReactionToaster): discard outdated reactions
- timeout for 30 seconds is set for now (allows 60 immediately fired recations to be shown during that interval) - should discard suspended reaction without showing them Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
parent
69719c8d31
commit
0ae7d0e0f4
1 changed files with 21 additions and 8 deletions
|
|
@ -177,26 +177,39 @@ export default {
|
|||
? this.actorStore.displayName || t('spreed', 'Guest')
|
||||
: this.getParticipantName(model),
|
||||
seed: Math.random(),
|
||||
timestamp: Date.now(),
|
||||
})
|
||||
},
|
||||
|
||||
processReactionsQueue() {
|
||||
if (this.reactionsQueue.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// Prevent spamming with reactions, if tab was suspended
|
||||
const now = Date.now()
|
||||
if (now < nextProcessedTimestamp) {
|
||||
return
|
||||
}
|
||||
|
||||
// Discard reactions, that should have been fired long ago
|
||||
if (this.reactionsQueue.at(0).timestamp < now - 30_000) {
|
||||
this.reactionsQueue = this.reactionsQueue.filter((reaction) => reaction.timestamp >= now - 30_000)
|
||||
|
||||
if (this.reactionsQueue.length === 0) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
nextProcessedTimestamp = now + TOAST_INTERVAL
|
||||
|
||||
if (this.reactionsQueue.length > 0) {
|
||||
// Move reactions from queue to visible array
|
||||
this.toasts.push(this.reactionsQueue.shift())
|
||||
// Move reactions from queue to visible array
|
||||
this.toasts.push(this.reactionsQueue.shift())
|
||||
|
||||
// Delete reactions from array after animation ends
|
||||
setTimeout(() => {
|
||||
this.toasts.shift()
|
||||
}, ANIMATION_LENGTH)
|
||||
}
|
||||
// Delete reactions from array after animation ends
|
||||
setTimeout(() => {
|
||||
this.toasts.shift()
|
||||
}, ANIMATION_LENGTH)
|
||||
},
|
||||
|
||||
getParticipantName(model) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue