From 42ccf06ff017247833df5f5fa5312f560d526432 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 7 Feb 2022 09:50:04 +1100 Subject: [PATCH] fetch last active users quicker on convo changes to public convo --- .../conversation/SessionConversation.tsx | 2 +- .../composition/CompositionBox.tsx | 10 +++++++--- ts/models/conversation.ts | 20 ++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index 3f975bf79..5b74f8674 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -123,7 +123,7 @@ export class SessionConversation extends React.Component { // if the newConversation changed, and is public, start our refresh members list if (newConversation.isPublic) { // this is a debounced call. - void this.updateMemberList(); + void this.updateMemberListBouncy(); // run this only once every minute if we don't change the visible conversation. // this is a heavy operation (like a few thousands members can be here) this.publicMembersRefreshTimeout = global.setInterval(this.updateMemberList, 60000); diff --git a/ts/components/conversation/composition/CompositionBox.tsx b/ts/components/conversation/composition/CompositionBox.tsx index 95f4fb26f..060aefca8 100644 --- a/ts/components/conversation/composition/CompositionBox.tsx +++ b/ts/components/conversation/composition/CompositionBox.tsx @@ -14,7 +14,7 @@ import { } from '../SessionStagedLinkPreview'; import { AbortController } from 'abort-controller'; import { SessionQuotedMessageComposition } from '../SessionQuotedMessageComposition'; -import { Mention, MentionsInput } from 'react-mentions'; +import { Mention, MentionsInput, SuggestionDataItem } from 'react-mentions'; import { MemberListItem } from '../../MemberListItem'; import autoBind from 'auto-bind'; import { getMediaPermissionsSettings } from '../../settings/SessionSettings'; @@ -467,7 +467,10 @@ class CompositionBoxInner extends React.Component { ); } - private fetchUsersForOpenGroup(query: any, callback: any) { + private fetchUsersForOpenGroup( + query: string, + callback: (data: Array) => void + ) { const mentionsInput = getMentionsInput(window?.inboxStore?.getState() || []); const filtered = mentionsInput @@ -481,10 +484,11 @@ class CompositionBoxInner extends React.Component { id: user.id, }; }) || []; + callback(filtered); } - private fetchUsersForGroup(query: any, callback: any) { + private fetchUsersForGroup(query: string, callback: (data: Array) => void) { let overridenQuery = query; if (!query) { overridenQuery = ''; diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 5dfa64440..f2a0dc02d 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1012,18 +1012,14 @@ export class ConversationModel extends Backbone.Model { window.storage.get(SettingsKey.settingsReadReceipt) || false ); if (window.storage.get(SettingsKey.settingsReadReceipt)) { - await Promise.all( - _.map(_.groupBy(read, 'sender'), async (receipts, sender) => { - const timestamps = _.map(receipts, 'timestamp').filter(t => !!t) as Array; - const receiptMessage = new ReadReceiptMessage({ - timestamp: Date.now(), - timestamps, - }); - - const device = new PubKey(sender); - await getMessageQueue().sendToPubKey(device, receiptMessage); - }) - ); + const timestamps = _.map(read, 'timestamp').filter(t => !!t) as Array; + const receiptMessage = new ReadReceiptMessage({ + timestamp: Date.now(), + timestamps, + }); + + const device = new PubKey(this.id); + await getMessageQueue().sendToPubKey(device, receiptMessage); } } }