Skip to content

Commit c98e14d

Browse files
committed
(fix) prevent message duplicates - stress test
1 parent fd2fcae commit c98e14d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ChatWindow/Room.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export default {
257257
messageReply: null,
258258
infiniteState: null,
259259
loadingMessages: false,
260+
loadingMoreMessages: false,
260261
file: null,
261262
imageFile: null,
262263
imageDimensions: { height: '32px', width: '10px' },
@@ -320,6 +321,7 @@ export default {
320321
321322
if (this.infiniteState) {
322323
this.infiniteState.loaded()
324+
setTimeout(() => (this.loadingMoreMessages = false), 0)
323325
} else if (newVal.length) {
324326
setTimeout(() => {
325327
element.scrollTo(options)
@@ -447,11 +449,15 @@ export default {
447449
this.resetMessage()
448450
},
449451
loadMoreMessages(infiniteState) {
452+
if (this.loadingMoreMessages) return
453+
450454
if (this.messagesLoaded || !this.room.roomId) {
451455
return infiniteState.complete()
452456
}
457+
453458
this.infiniteState = infiniteState
454459
this.$emit('fetchMessages')
460+
this.loadingMoreMessages = true
455461
},
456462
messageActionHandler({ action, message }) {
457463
switch (action.name) {

0 commit comments

Comments
 (0)