Skip to content

Commit

Permalink
refactor: Use existing next-message-id data
Browse files Browse the repository at this point in the history
Signed-off-by: Souptik Datta <[email protected]>
  • Loading branch information
Souptik2001 committed Sep 23, 2024
1 parent fac9f7a commit f775929
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default {
itemType,
referenceId: this.message.referenceId,
file: this.message.messageParameters[p],
nextMessageId: this.nextMessageId,
},
}
} else if (type === 'deck-card') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export default {
type: Number,
default: 0,
},
token: {
type: String,
required: true,
nextMessageId: {
type: Number,
default: 0,
},
},
Expand All @@ -85,35 +85,6 @@ export default {
return generateRemoteUrl(`dav/files/${userId}`) + encodePath(this.internalAbsolutePath)
}
},
nextVoiceMessageID() {
const messagesList = this.$store.getters.messagesList(this.token)
let maximumAllowedDistance = 0
let currentMessageFound = false
for (const message of messagesList) {
// Return null if no voice-message found within the maximum allowed distance.
if (maximumAllowedDistance < 0) {
return null
}
// If current message is already found and the current iterating message is of type voice-message then return its ID.
if (currentMessageFound && message.messageType === 'voice-message') {
return message.id
} else if (currentMessageFound) {
maximumAllowedDistance--
continue
}
// If current message is found then set the flag to true.
if (message.id === this.messageId) {
currentMessageFound = true
}
}
return null
},
},
mounted() {
Expand All @@ -128,12 +99,12 @@ export default {
t,
handleEnded() {
// Return early if next voice message ID not found
if (!this.nextVoiceMessageID) {
// Return early if next message ID not found
if (!this.nextMessageId) {
return
}
EventBus.emit('audio-player-ended', this.nextVoiceMessageID)
EventBus.emit('audio-player-ended', this.nextMessageId)
},
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export default {
type: String,
default: '',
},
nextMessageId: {
type: [String, Number],
default: 0,
},
},
emits: ['remove-file'],
Expand Down Expand Up @@ -251,7 +256,7 @@ export default {
path: this.file.path,
link: this.file.link,
messageId: Number(this.messageId),
token: this.token,
nextMessageId: Number(this.nextMessageId),
}
}
return {
Expand Down

0 comments on commit f775929

Please sign in to comment.