Skip to content

Commit

Permalink
Merge pull request #13243 from nextcloud/fix/8148/call-just-ended
Browse files Browse the repository at this point in the history
  • Loading branch information
Antreesy authored Sep 11, 2024
2 parents 229f3b0 + 35c7a4c commit 7c932c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export default {

startCallButtonDisabled() {
return this.disabled
|| (this.$store.getters.callHasJustEnded && !this.hasCall)
|| (!this.conversation.canStartCall && !this.hasCall)
|| this.isInLobby
|| this.conversation.readOnly
Expand Down Expand Up @@ -290,6 +291,10 @@ export default {
return t('spreed', 'Nextcloud Talk was updated, you need to reload the page before you can start or join a call.')
}

if (this.$store.getters.callHasJustEnded) {
return t('spreed', 'This call has just ended')
}

if (this.callButtonTooltipText) {
return this.callButtonTooltipText
}
Expand Down Expand Up @@ -352,6 +357,12 @@ export default {
},
},

watch: {
token() {
this.$store.dispatch('resetCallHasJustEnded')
}
},

mounted() {
this.callEnabled = loadState('spreed', 'call_enabled')
},
Expand Down
24 changes: 24 additions & 0 deletions src/store/callViewStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const state = {
qualityWarningTooltipDismissed: false,
participantRaisedHands: {},
backgroundImageAverageColorCache: {},
callHasJustEnded: null,
}

const getters = {
Expand All @@ -34,6 +35,7 @@ const getters = {
lastIsGrid: (state) => state.lastIsGrid,
lastIsStripeOpen: (state) => state.lastIsStripeOpen,
presentationStarted: (state) => state.presentationStarted,
callHasJustEnded: (state) => !!state.callHasJustEnded,
selectedVideoPeerId: (state) => {
return state.selectedVideoPeerId
},
Expand Down Expand Up @@ -107,6 +109,9 @@ const mutations = {
clearBackgroundImageAverageColorCache(state) {
state.backgroundImageAverageColorCache = {}
},
setCallHasJustEnded(state, value) {
state.callHasJustEnded = value
},
}

const actions = {
Expand Down Expand Up @@ -240,6 +245,25 @@ const actions = {
isEmptyCallView(context, value) {
context.commit('isEmptyCallView', value)
},

setCallHasJustEnded(context, timestamp) {
// Check the time difference between the current time and the call end time.
// Then, disable the CallButton for the remaining time until 10 seconds after the call ends.
const timeDiff = Math.abs(Date.now() / 1000 - timestamp)
if (10000 - timeDiff < 0) {
return
}
clearTimeout(context.state.callHasJustEnded)
const timeoutId = setTimeout(() => {
context.dispatch('resetCallHasJustEnded')
}, Math.max(0, 10000 - timeDiff))
context.commit('setCallHasJustEnded', timeoutId)
},

resetCallHasJustEnded(context) {
clearTimeout(context.state.callHasJustEnded)
context.commit('setCallHasJustEnded', null)
}
}

export default { state, mutations, getters, actions }
6 changes: 6 additions & 0 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,12 @@ const actions = {
lastActivity: message.timestamp,
})
}
if (message.systemMessage === 'call_ended_everyone'
&& conversation.type !== CONVERSATION.TYPE.ONE_TO_ONE
&& !(message.actorId === context.getters.getActorId()
&& message.actorType === context.getters.getActorType())) {
context.dispatch('setCallHasJustEnded', message.timestamp)
}
}

// in case we encounter an already read message, reset the counter
Expand Down

0 comments on commit 7c932c8

Please sign in to comment.