From 6c2c0883ce42129c5aa135dce80541a9ff5927fe Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sat, 30 May 2020 13:47:46 +0300 Subject: [PATCH] Use since_id when pulling the current chat messages --- src/components/chat/chat.js | 6 +++++- src/modules/statuses.js | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 6a5eb422..2ca7eaee 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -91,6 +91,7 @@ const Chat = { currentUser: state => state.users.currentUser, isMobileLayout: state => state.interface.mobileLayout, openedChats: state => state.chats.openedChats, + openedChatMessageServices: state => state.chats.openedChatMessageServices, windowHeight: state => state.interface.layoutHeight }) }, @@ -263,7 +264,10 @@ const Chat = { positionBeforeLoading = this.getPosition() previousScrollTop = this.$refs.scrollable.scrollTop } - this.backendInteractor.chatMessages({ id: chatId, maxId }) + const chatMessageService = this.openedChatMessageServices[chatId] + const sinceId = chatMessageService.lastMessage && chatMessageService.lastMessage.id + + this.backendInteractor.chatMessages({ id: chatId, maxId, sinceId }) .then((messages) => { let bottomedOut = this.bottomedOut() this.loadingOlderMessages = false diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 2b93b995..6ed71c24 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -332,11 +332,11 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot dispatch('fetchEmojiReactionsBy', notification.status.id) } - if (notification.type === 'pleroma:chat_mention') { - dispatch('addChatMessages', { chatId: notification.chatMessage.chat_id, messages: [notification.chatMessage] }) - dispatch('updateChatByAccountId', { accountId: notification.from_profile.id }) - // dispatch('updateUnreadChatCount', { userId, unreadChatCount }) - } + // if (notification.type === 'pleroma:chat_mention') { + // dispatch('addChatMessages', { chatId: notification.chatMessage.chat_id, messages: [notification.chatMessage] }) + // dispatch('updateChatByAccountId', { accountId: notification.from_profile.id }) + // // dispatch('updateUnreadChatCount', { userId, unreadChatCount }) + // } // Only add a new notification if we don't have one for the same action if (!state.notifications.idStore.hasOwnProperty(notification.id)) {