From 8975589bca81ff6eb84084047bf74e16ee5d1cd7 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 8 Sep 2020 10:44:08 +0300 Subject: [PATCH 1/8] fix vue warnings and errors --- .../contrast_ratio/contrast_ratio.vue | 7 +++-- src/components/poll/poll.vue | 2 ++ .../tabs/theme_tab/theme_tab.vue | 30 +++++++++---------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/components/contrast_ratio/contrast_ratio.vue b/src/components/contrast_ratio/contrast_ratio.vue index ba92bc17..9dc871b6 100644 --- a/src/components/contrast_ratio/contrast_ratio.vue +++ b/src/components/contrast_ratio/contrast_ratio.vue @@ -39,13 +39,16 @@ export default { props: { large: { - required: false + required: false, + type: Boolean, + default: false }, // TODO: Make theme switcher compute theme initially so that contrast // component won't be called without contrast data contrast: { required: false, - type: Object + type: Object, + default: () => ({}) } }, computed: { diff --git a/src/components/poll/poll.vue b/src/components/poll/poll.vue index 1858f3e1..fedb92c8 100644 --- a/src/components/poll/poll.vue +++ b/src/components/poll/poll.vue @@ -17,7 +17,9 @@ {{ percentageForOption(option.votes_count) }}% + +
@@ -359,7 +359,7 @@ />
@@ -740,57 +740,57 @@
{{ $t('settings.style.advanced_colors.chat.incoming') }}
{{ $t('settings.style.advanced_colors.chat.outgoing') }}
From afb2241a5ba057f5d21abb23fa5400e461ba8cf5 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 8 Sep 2020 16:29:10 +0300 Subject: [PATCH 2/8] change a eslint disable to nextline only --- src/components/poll/poll.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/poll/poll.vue b/src/components/poll/poll.vue index fedb92c8..5f54b416 100644 --- a/src/components/poll/poll.vue +++ b/src/components/poll/poll.vue @@ -17,9 +17,8 @@ {{ percentageForOption(option.votes_count) }}% - + -
Date: Wed, 16 Sep 2020 05:08:12 +0300 Subject: [PATCH 3/8] Fix the chat list order and last message timestamp updates --- src/modules/chats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/chats.js b/src/modules/chats.js index c7609018..aef16322 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -143,6 +143,7 @@ const chats = { const isNewMessage = (chat.lastMessage && chat.lastMessage.id) !== (updatedChat.lastMessage && updatedChat.lastMessage.id) chat.lastMessage = updatedChat.lastMessage chat.unread = updatedChat.unread + chat.updated_at = updatedChat.updated_at if (isNewMessage && chat.unread) { newChatMessageSideEffects(updatedChat) } From 8c4514013d5a53218830a82a6ac46f5969edd69b Mon Sep 17 00:00:00 2001 From: eugenijm Date: Wed, 16 Sep 2020 02:34:19 +0300 Subject: [PATCH 4/8] Fix chat messages being missed when the streaming is disabled and the messages are sent by both participants simultaneously --- src/components/chat/chat.js | 12 +++++++---- src/modules/chats.js | 20 +++---------------- src/services/chat_service/chat_service.js | 17 +++++++++------- .../chat_service/chat_service.spec.js | 10 +++++----- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 9c4e5b05..803abf69 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -204,9 +204,9 @@ const Chat = { } }, readChat () { - if (!(this.currentChatMessageService && this.currentChatMessageService.lastMessage)) { return } + if (!(this.currentChatMessageService && this.currentChatMessageService.maxId)) { return } if (document.hidden) { return } - const lastReadId = this.currentChatMessageService.lastMessage.id + const lastReadId = this.currentChatMessageService.maxId this.$store.dispatch('readChat', { id: this.currentChat.id, lastReadId }) }, bottomedOut (offset) { @@ -244,7 +244,7 @@ const Chat = { const chatId = chatMessageService.chatId const fetchOlderMessages = !!maxId - const sinceId = fetchLatest && chatMessageService.lastMessage && chatMessageService.lastMessage.id + const sinceId = fetchLatest && chatMessageService.maxId this.backendInteractor.chatMessages({ id: chatId, maxId, sinceId }) .then((messages) => { @@ -303,7 +303,11 @@ const Chat = { return this.backendInteractor.sendChatMessage(params) .then(data => { - this.$store.dispatch('addChatMessages', { chatId: this.currentChat.id, messages: [data] }).then(() => { + this.$store.dispatch('addChatMessages', { + chatId: this.currentChat.id, + messages: [data], + updateMaxId: false + }).then(() => { this.$nextTick(() => { this.handleResize() // When the posting form size changes because of a media attachment, we need an extra resize diff --git a/src/modules/chats.js b/src/modules/chats.js index c7609018..e752c6df 100644 --- a/src/modules/chats.js +++ b/src/modules/chats.js @@ -181,30 +181,16 @@ const chats = { setChatsLoading (state, { value }) { state.chats.loading = value }, - addChatMessages (state, { commit, chatId, messages }) { + addChatMessages (state, { chatId, messages, updateMaxId }) { const chatMessageService = state.openedChatMessageServices[chatId] if (chatMessageService) { - chatService.add(chatMessageService, { messages: messages.map(parseChatMessage) }) - commit('refreshLastMessage', { chatId }) + chatService.add(chatMessageService, { messages: messages.map(parseChatMessage), updateMaxId }) } }, - refreshLastMessage (state, { chatId }) { - const chatMessageService = state.openedChatMessageServices[chatId] - if (chatMessageService) { - const chat = getChatById(state, chatId) - if (chat) { - chat.lastMessage = chatMessageService.lastMessage - if (chatMessageService.lastMessage) { - chat.updated_at = chatMessageService.lastMessage.created_at - } - } - } - }, - deleteChatMessage (state, { commit, chatId, messageId }) { + deleteChatMessage (state, { chatId, messageId }) { const chatMessageService = state.openedChatMessageServices[chatId] if (chatMessageService) { chatService.deleteMessage(chatMessageService, messageId) - commit('refreshLastMessage', { chatId }) } }, resetChatNewMessageCount (state, _value) { diff --git a/src/services/chat_service/chat_service.js b/src/services/chat_service/chat_service.js index b60a889b..95c69482 100644 --- a/src/services/chat_service/chat_service.js +++ b/src/services/chat_service/chat_service.js @@ -8,7 +8,7 @@ const empty = (chatId) => { lastSeenTimestamp: 0, chatId: chatId, minId: undefined, - lastMessage: undefined + maxId: undefined } } @@ -18,7 +18,7 @@ const clear = (storage) => { storage.newMessageCount = 0 storage.lastSeenTimestamp = 0 storage.minId = undefined - storage.lastMessage = undefined + storage.maxId = undefined } const deleteMessage = (storage, messageId) => { @@ -26,8 +26,9 @@ const deleteMessage = (storage, messageId) => { storage.messages = storage.messages.filter(m => m.id !== messageId) delete storage.idIndex[messageId] - if (storage.lastMessage && (storage.lastMessage.id === messageId)) { - storage.lastMessage = _.maxBy(storage.messages, 'id') + if (storage.maxId === messageId) { + const lastMessage = _.maxBy(storage.messages, 'id') + storage.maxId = lastMessage.id } if (storage.minId === messageId) { @@ -36,7 +37,7 @@ const deleteMessage = (storage, messageId) => { } } -const add = (storage, { messages: newMessages }) => { +const add = (storage, { messages: newMessages, updateMaxId = true }) => { if (!storage) { return } for (let i = 0; i < newMessages.length; i++) { const message = newMessages[i] @@ -48,8 +49,10 @@ const add = (storage, { messages: newMessages }) => { storage.minId = message.id } - if (!storage.lastMessage || message.id > storage.lastMessage.id) { - storage.lastMessage = message + if (!storage.maxId || message.id > storage.maxId) { + if (updateMaxId) { + storage.maxId = message.id + } } if (!storage.idIndex[message.id]) { diff --git a/test/unit/specs/services/chat_service/chat_service.spec.js b/test/unit/specs/services/chat_service/chat_service.spec.js index 3ee9839d..2eb89a2d 100644 --- a/test/unit/specs/services/chat_service/chat_service.spec.js +++ b/test/unit/specs/services/chat_service/chat_service.spec.js @@ -33,12 +33,12 @@ describe('chatService', () => { const chat = chatService.empty() chatService.add(chat, { messages: [ message1 ] }) - expect(chat.lastMessage.id).to.eql(message1.id) + expect(chat.maxId).to.eql(message1.id) expect(chat.minId).to.eql(message1.id) expect(chat.newMessageCount).to.eql(1) chatService.add(chat, { messages: [ message2 ] }) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message1.id) expect(chat.newMessageCount).to.eql(2) @@ -60,15 +60,15 @@ describe('chatService', () => { chatService.add(chat, { messages: [ message2 ] }) chatService.add(chat, { messages: [ message3 ] }) - expect(chat.lastMessage.id).to.eql(message3.id) + expect(chat.maxId).to.eql(message3.id) expect(chat.minId).to.eql(message1.id) chatService.deleteMessage(chat, message3.id) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message1.id) chatService.deleteMessage(chat, message1.id) - expect(chat.lastMessage.id).to.eql(message2.id) + expect(chat.maxId).to.eql(message2.id) expect(chat.minId).to.eql(message2.id) }) }) From d6fe4f6a4fa4c8fb928bcd187e605c76f985d06d Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 10:27:31 +0300 Subject: [PATCH 5/8] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18dafa8e..c56ac821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ## [Unreleased patch] +### Fixed +- Fixed chats list not updating its order when new messages come in +- Fixed chat messages sometimes getting lost when you receive a message at the same time + + +## [2.1.1] - 2020-09-08 ### Changed - Polls will be hidden with status content if "Collapse posts with subjects" is enabled and the post is collapsed. @@ -13,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Autocomplete won't stop at the second @, so it'll still work with "@lain@l" and not start over. - Fixed weird autocomplete behavior when you write ":custom_emoji: ?" + ## [2.1.0] - 2020-08-28 ### Added - Autocomplete domains from list of known instances From 1b811d8b931706927d8fa096435b2c272eb0d7ef Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 11:29:10 +0300 Subject: [PATCH 6/8] change side drawer to use shoutbox name --- src/components/side_drawer/side_drawer.vue | 2 +- src/i18n/en.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 0587ee02..b17813c3 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -90,7 +90,7 @@ @click="toggleDrawer" > - {{ $t("nav.chat") }} + {{ $t("shoutbox.title") }} diff --git a/src/i18n/en.json b/src/i18n/en.json index 8540f551..027e99be 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -113,7 +113,6 @@ "about": "About", "administration": "Administration", "back": "Back", - "chat": "Local Chat", "friend_requests": "Follow Requests", "mentions": "Mentions", "interactions": "Interactions", From 20d33c2fbc1e3cf9cdbab94c26b138acd505d001 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 16 Sep 2020 11:53:54 +0300 Subject: [PATCH 7/8] change icon to a megaphone --- src/components/chat_panel/chat_panel.vue | 2 +- src/components/side_drawer/side_drawer.vue | 2 +- static/fontello.json | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/chat_panel/chat_panel.vue b/src/components/chat_panel/chat_panel.vue index ca529b5a..570435e7 100644 --- a/src/components/chat_panel/chat_panel.vue +++ b/src/components/chat_panel/chat_panel.vue @@ -63,7 +63,7 @@ @click.stop.prevent="togglePanel" >
- + {{ $t('shoutbox.title') }}
diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index b17813c3..eda5a68c 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -90,7 +90,7 @@ @click="toggleDrawer" > - {{ $t("shoutbox.title") }} + {{ $t("shoutbox.title") }} diff --git a/static/fontello.json b/static/fontello.json index 706800cd..b0136fd9 100644 --- a/static/fontello.json +++ b/static/fontello.json @@ -405,6 +405,12 @@ "css": "block", "code": 59434, "src": "fontawesome" + }, + { + "uid": "3e674995cacc2b09692c096ea7eb6165", + "css": "megaphone", + "code": 59435, + "src": "fontawesome" } ] } \ No newline at end of file From 8ca0586c0f75d1ea70268f0951edb4dbbfc85271 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Thu, 17 Sep 2020 20:15:08 +0300 Subject: [PATCH 8/8] update changelog for 2.1.2 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56ac821..aed71445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ## [Unreleased patch] +## [2.1.2] - 2020-09-17 ### Fixed - Fixed chats list not updating its order when new messages come in - Fixed chat messages sometimes getting lost when you receive a message at the same time