Skip to content

Commit

Permalink
fix(conversation): overwrite hasCall param by system messages
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 10, 2024
1 parent db95ebb commit 11b5cf4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/components/MediaSettings/MediaSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export default {
},

hasCall() {
return this.conversation.hasCall || this.conversation.hasCallOverwrittenByChat
return this.conversation.hasCall
},

isCurrentlyRecording() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default {
},

hasCall() {
return this.conversation.hasCall || this.conversation.hasCallOverwrittenByChat
return this.conversation.hasCall
},

startCallButtonDisabled() {
Expand Down
20 changes: 10 additions & 10 deletions src/store/conversationsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,6 @@ const mutations = {
}
},

overwriteHasCallByChat(state, { token, hasCall }) {
if (hasCall) {
Vue.set(state.conversations[token], 'hasCallOverwrittenByChat', hasCall)
} else {
Vue.delete(state.conversations[token], 'hasCallOverwrittenByChat')
}
},

setNotificationLevel(state, { token, notificationLevel }) {
Vue.set(state.conversations[token], 'notificationLevel', notificationLevel)
},
Expand Down Expand Up @@ -792,8 +784,16 @@ const actions = {
commit('updateConversationLastReadMessage', { token, lastReadMessage })
},

async overwriteHasCallByChat({ commit }, { token, hasCall }) {
commit('overwriteHasCallByChat', { token, hasCall })
async overwriteHasCallByChat({ commit, dispatch }, { token, hasCall, lastActivity }) {
dispatch('setConversationProperties', {
token,
properties: {
hasCall,
callFlag: hasCall ? PARTICIPANT.CALL_FLAG.IN_CALL : PARTICIPANT.CALL_FLAG.DISCONNECTED,
lastActivity,
callStartTime: hasCall ? lastActivity : 0,
}
})
},

async fetchConversation({ dispatch }, { token }) {
Expand Down
20 changes: 3 additions & 17 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1090,25 +1090,11 @@ const actions = {
// Overwrite the conversation.hasCall property so people can join
// after seeing the message in the chat.
if (conversation && conversation.lastMessage && message.id > conversation.lastMessage.id) {
if (message.systemMessage === 'call_started') {
if (['call_started', 'call_ended', 'call_ended_everyone', 'call_missed'].includes(message.systemMessage)) {
context.dispatch('overwriteHasCallByChat', {
token,
hasCall: true,
})
context.dispatch('setConversationProperties', {
token: message.token,
properties: { callStartTime: message.timestamp },
})
} else if (message.systemMessage === 'call_ended'
|| message.systemMessage === 'call_ended_everyone'
|| message.systemMessage === 'call_missed') {
context.dispatch('overwriteHasCallByChat', {
token,
hasCall: false,
})
context.dispatch('setConversationProperties', {
token: message.token,
properties: { callStartTime: 0 },
hasCall: message.systemMessage === 'call_started',
lastActivity: message.timestamp,
})
}
}
Expand Down

0 comments on commit 11b5cf4

Please sign in to comment.