Compare commits

...
Author SHA1 Message Date
Shivam Mishra 2c505eef43 refactor: don't call setActiveChat 2023-11-30 12:56:38 +05:30
Shivam Mishra 4429e95f2b refactor: move fetching logic to onScrollToMessage 2023-11-30 12:56:38 +05:30
Shivam Mishra 61c07472e0 Revert "feat: remove click action"
This reverts commit 39e748bd739d8849a01e51b78e5db3c440d7c803.
2023-11-30 12:56:38 +05:30
Shivam Mishra 09969af10c Revert "chore: remove force option"
This reverts commit c65361ba82d7f0fd225d0c7aa51c9c5055e7fff6.
2023-11-30 12:55:25 +05:30
Shivam Mishra f830821e0a Revert "chore: remove behavior option"
This reverts commit b09c946af35f8984aa852d8658eb4745cc5c5d00.
2023-11-30 12:55:25 +05:30
7 changed files with 31 additions and 14 deletions
@@ -28,6 +28,7 @@
:message="inReplyTo" :message="inReplyTo"
:message-type="data.message_type" :message-type="data.message_type"
:parent-has-attachments="hasAttachments" :parent-has-attachments="hasAttachments"
@click="navigateToMessage"
/> />
<bubble-text <bubble-text
v-if="data.content" v-if="data.content"
@@ -519,6 +520,13 @@ export default {
this.showBackgroundHighlight = false; this.showBackgroundHighlight = false;
}, HIGHLIGHT_TIMER); }, HIGHLIGHT_TIMER);
}, },
async navigateToMessage() {
this.$nextTick(() => {
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, {
messageId: this.inReplyToMessageId,
});
});
},
}, },
}; };
</script> </script>
@@ -377,12 +377,19 @@ export default {
removeBusListeners() { removeBusListeners() {
bus.$off(BUS_EVENTS.SCROLL_TO_MESSAGE, this.onScrollToMessage); bus.$off(BUS_EVENTS.SCROLL_TO_MESSAGE, this.onScrollToMessage);
}, },
onScrollToMessage({ messageId = '' } = {}) { async onScrollToMessage({ messageId }) {
// TODO: check if the message is already loaded
await this.$store.dispatch('setActiveChat', {
data: this.currentChat,
after: messageId,
force: true,
});
this.$nextTick(() => { this.$nextTick(() => {
const messageElement = document.getElementById('message' + messageId); const messageElement = document.getElementById('message' + messageId);
if (messageElement) { if (messageElement) {
this.isProgrammaticScroll = true; this.isProgrammaticScroll = true;
messageElement.scrollIntoView({ behavior: 'smooth' }); messageElement.scrollIntoView();
this.fetchPreviousMessages(); this.fetchPreviousMessages();
} else { } else {
this.scrollToBottom(); this.scrollToBottom();
@@ -29,6 +29,7 @@
v-if="shouldShowReplyToMessage" v-if="shouldShowReplyToMessage"
:message="inReplyTo" :message="inReplyTo"
@dismiss="resetReplyToMessage" @dismiss="resetReplyToMessage"
@navigate-to-message="navigateToMessage"
/> />
<canned-response <canned-response
v-if="showMentions && hasSlashCommand" v-if="showMentions && hasSlashCommand"
@@ -1158,6 +1159,12 @@ export default {
LocalStorage.deleteFromJsonStore(replyStorageKey, this.conversationId); LocalStorage.deleteFromJsonStore(replyStorageKey, this.conversationId);
bus.$emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE); bus.$emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE);
}, },
navigateToMessage(messageId) {
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, {
messageId,
behavior: 'instant',
});
},
onNewConversationModalActive(isActive) { onNewConversationModalActive(isActive) {
// Issue is if the new conversation modal is open and we drag and drop the file // Issue is if the new conversation modal is open and we drag and drop the file
// then the file is not getting attached to the new conversation modal // then the file is not getting attached to the new conversation modal
@@ -1,6 +1,7 @@
<template> <template>
<div <div
class="reply-editor bg-slate-50 dark:bg-slate-800 rounded-md py-1 pl-2 pr-1 text-xs tracking-wide mt-2 flex items-center gap-1.5 -mx-2" class="reply-editor bg-slate-50 dark:bg-slate-800 rounded-md py-1 pl-2 pr-1 text-xs tracking-wide mt-2 flex items-center gap-1.5 -mx-2 cursor-pointer"
@click="$emit('navigate-to-message', message.id)"
> >
<fluent-icon class="flex-shrink-0 icon" icon="arrow-reply" size="14" /> <fluent-icon class="flex-shrink-0 icon" icon="arrow-reply" size="14" />
<div class="flex-grow gap-1 mt-px text-xs truncate"> <div class="flex-grow gap-1 mt-px text-xs truncate">
@@ -1,12 +1,13 @@
<template> <template>
<div <div
class="px-2 py-1.5 rounded-sm min-w-[10rem] mb-2" class="px-2 py-1.5 -mx-2 rounded-sm min-w-[15rem] mb-2 cursor-pointer"
:class="{ :class="{
'bg-slate-50 dark:bg-slate-600 dark:text-slate-50': 'bg-slate-50 dark:bg-slate-600 dark:text-slate-50':
messageType === MESSAGE_TYPE.INCOMING, messageType === MESSAGE_TYPE.INCOMING,
'bg-woot-600 text-woot-50': messageType === MESSAGE_TYPE.OUTGOING, 'bg-woot-600 text-woot-50': messageType === MESSAGE_TYPE.OUTGOING,
'-mx-2': !parentHasAttachments, '-mx-2': !parentHasAttachments,
}" }"
@click="$emit('click')"
> >
<message-preview <message-preview
:message="message" :message="message"
@@ -163,14 +163,7 @@ export default {
return; return;
} }
const { messageId } = this.$route.query; const { messageId } = this.$route.query;
this.$store bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, { messageId });
.dispatch('setActiveChat', {
data: selectedConversation,
after: messageId,
})
.then(() => {
bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE, { messageId });
});
} else { } else {
this.$store.dispatch('clearSelectedState'); this.$store.dispatch('clearSelectedState');
} }
@@ -160,10 +160,10 @@ const actions = {
}); });
}, },
async setActiveChat({ commit, dispatch }, { data, after }) { async setActiveChat({ commit, dispatch }, { data, after, force = false }) {
commit(types.SET_CURRENT_CHAT_WINDOW, data); commit(types.SET_CURRENT_CHAT_WINDOW, data);
commit(types.CLEAR_ALL_MESSAGES_LOADED); commit(types.CLEAR_ALL_MESSAGES_LOADED);
if (data.dataFetched === undefined) { if (data.dataFetched === undefined || force) {
try { try {
await dispatch('fetchPreviousMessages', { await dispatch('fetchPreviousMessages', {
after, after,