fix: message URL navigation won't work

This commit is contained in:
Shivam Mishra
2023-11-30 20:46:37 +05:30
parent 8a7a5ca8d7
commit 97301c3080
2 changed files with 13 additions and 12 deletions
@@ -378,12 +378,13 @@ export default {
bus.$off(BUS_EVENTS.SCROLL_TO_MESSAGE, this.onScrollToMessage);
},
async onScrollToMessage({ messageId }) {
// TODO: check if the message is already loaded
await this.$store.dispatch('setActiveChat', {
data: this.currentChat,
after: messageId,
force: true,
});
if (messageId) {
await this.$store.dispatch('setActiveChat', {
data: this.currentChat,
after: messageId,
force: true,
});
}
this.$nextTick(() => {
const messageElement = document.getElementById('message' + messageId);
@@ -163,14 +163,14 @@ export default {
return;
}
const { messageId } = this.$route.query;
if (messageId) {
// this will automatically set the active chat
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, { messageId });
} else {
this.$store.dispatch('setActiveChat', {
this.$store
.dispatch('setActiveChat', {
data: selectedConversation,
after: messageId,
})
.then(() => {
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, { messageId });
});
}
} else {
this.$store.dispatch('clearSelectedState');
}