feat: Allow agents/admins to copy the link to a message (#5912)

This commit is contained in:
Pranav Raj S
2023-03-26 22:58:42 -07:00
committed by GitHub
parent 1e8881577a
commit 6000028f64
9 changed files with 107 additions and 33 deletions

View File

@@ -192,11 +192,6 @@ export default {
(!this.listLoadingStatus && this.isLoadingPrevious)
);
},
shouldLoadMoreChats() {
return !this.listLoadingStatus && !this.isLoadingPrevious;
},
conversationType() {
const { additional_attributes: additionalAttributes } = this.currentChat;
const type = additionalAttributes ? additionalAttributes.type : '';
@@ -302,8 +297,16 @@ export default {
setSelectedTweet(tweetId) {
this.selectedTweetId = tweetId;
},
onScrollToMessage() {
this.$nextTick(() => this.scrollToBottom());
onScrollToMessage({ messageId = '' } = {}) {
this.$nextTick(() => {
const messageElement = document.getElementById('message' + messageId);
if (messageElement) {
messageElement.scrollIntoView({ behavior: 'smooth' });
this.fetchPreviousMessages();
} else {
this.scrollToBottom();
}
});
this.makeMessagesRead();
},
showPopoutReplyBox() {
@@ -354,34 +357,42 @@ export default {
this.scrollTopBeforeLoad = this.conversationPanel.scrollTop;
},
handleScroll(e) {
bus.$emit(BUS_EVENTS.ON_MESSAGE_LIST_SCROLL);
async fetchPreviousMessages(scrollTop = 0) {
this.setScrollParams();
const shouldLoadMoreMessages =
this.getMessages.dataFetched === true &&
!this.listLoadingStatus &&
!this.isLoadingPrevious;
const dataFetchCheck =
this.getMessages.dataFetched === true && this.shouldLoadMoreChats;
if (
e.target.scrollTop < 100 &&
scrollTop < 100 &&
!this.isLoadingPrevious &&
dataFetchCheck
shouldLoadMoreMessages
) {
this.isLoadingPrevious = true;
this.$store
.dispatch('fetchPreviousMessages', {
try {
await this.$store.dispatch('fetchPreviousMessages', {
conversationId: this.currentChat.id,
before: this.getMessages.messages[0].id,
})
.then(() => {
const heightDifference =
this.conversationPanel.scrollHeight - this.heightBeforeLoad;
this.conversationPanel.scrollTop =
this.scrollTopBeforeLoad + heightDifference;
this.isLoadingPrevious = false;
this.setScrollParams();
});
const heightDifference =
this.conversationPanel.scrollHeight - this.heightBeforeLoad;
this.conversationPanel.scrollTop =
this.scrollTopBeforeLoad + heightDifference;
this.setScrollParams();
} catch (error) {
// Ignore Error
} finally {
this.isLoadingPrevious = false;
}
}
},
handleScroll(e) {
bus.$emit(BUS_EVENTS.ON_MESSAGE_LIST_SCROLL);
this.fetchPreviousMessages(e.target.scrollTop);
},
makeMessagesRead() {
this.$store.dispatch('markMessagesRead', { id: this.currentChat.id });
},