Skip to content

Commit

Permalink
Merge pull request #9603 from nextcloud/bugfix/9548/no-start-typing-f…
Browse files Browse the repository at this point in the history
…or-each-keystroke

fix(chat): Don't send startTyping signaling message for each keystroke
  • Loading branch information
ShGKme authored May 24, 2023
2 parents f8070eb + 421e21c commit ab5fc94
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,18 @@ export default {

// Enable signal sending, only if indicator for this input is on
if (this.showTypingStatus) {
clearTimeout(this.typingTimeout)

if (!newValue) {
this.$store.dispatch('setTyping', { typing: false })
this.resetTypingIndicator()
return
}

this.typingTimeout = setTimeout(() => {
this.$store.dispatch('setTyping', { typing: false })
}, 5000)
this.$store.dispatch('setTyping', { typing: true })
if (!this.typingTimeout) {
this.typingTimeout = setTimeout(() => {
this.resetTypingIndicator()
}, 5000)
this.$store.dispatch('setTyping', { typing: true })
}

}
},

Expand All @@ -404,7 +405,7 @@ export default {
} else {
this.text = ''
}
this.$store.dispatch('setTyping', { typing: false })
this.resetTypingIndicator()
},
},

Expand All @@ -426,6 +427,13 @@ export default {
},

methods: {
resetTypingIndicator() {
if (this.typingTimeout) {
clearTimeout(this.typingTimeout)
}
this.$store.dispatch('setTyping', { typing: false })
},

handleUploadStart() {
// refocus on upload start as the user might want to type again while the upload is running
this.focusInput()
Expand Down

0 comments on commit ab5fc94

Please sign in to comment.