fetch last active users quicker on convo changes to public convo

pull/2157/head
Audric Ackermann 3 years ago
parent a19a6a33c7
commit 42ccf06ff0
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -123,7 +123,7 @@ export class SessionConversation extends React.Component<Props, State> {
// if the newConversation changed, and is public, start our refresh members list // if the newConversation changed, and is public, start our refresh members list
if (newConversation.isPublic) { if (newConversation.isPublic) {
// this is a debounced call. // 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. // 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 is a heavy operation (like a few thousands members can be here)
this.publicMembersRefreshTimeout = global.setInterval(this.updateMemberList, 60000); this.publicMembersRefreshTimeout = global.setInterval(this.updateMemberList, 60000);

@ -14,7 +14,7 @@ import {
} from '../SessionStagedLinkPreview'; } from '../SessionStagedLinkPreview';
import { AbortController } from 'abort-controller'; import { AbortController } from 'abort-controller';
import { SessionQuotedMessageComposition } from '../SessionQuotedMessageComposition'; import { SessionQuotedMessageComposition } from '../SessionQuotedMessageComposition';
import { Mention, MentionsInput } from 'react-mentions'; import { Mention, MentionsInput, SuggestionDataItem } from 'react-mentions';
import { MemberListItem } from '../../MemberListItem'; import { MemberListItem } from '../../MemberListItem';
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import { getMediaPermissionsSettings } from '../../settings/SessionSettings'; import { getMediaPermissionsSettings } from '../../settings/SessionSettings';
@ -467,7 +467,10 @@ class CompositionBoxInner extends React.Component<Props, State> {
); );
} }
private fetchUsersForOpenGroup(query: any, callback: any) { private fetchUsersForOpenGroup(
query: string,
callback: (data: Array<SuggestionDataItem>) => void
) {
const mentionsInput = getMentionsInput(window?.inboxStore?.getState() || []); const mentionsInput = getMentionsInput(window?.inboxStore?.getState() || []);
const filtered = const filtered =
mentionsInput mentionsInput
@ -481,10 +484,11 @@ class CompositionBoxInner extends React.Component<Props, State> {
id: user.id, id: user.id,
}; };
}) || []; }) || [];
callback(filtered); callback(filtered);
} }
private fetchUsersForGroup(query: any, callback: any) { private fetchUsersForGroup(query: string, callback: (data: Array<SuggestionDataItem>) => void) {
let overridenQuery = query; let overridenQuery = query;
if (!query) { if (!query) {
overridenQuery = ''; overridenQuery = '';

@ -1012,18 +1012,14 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
window.storage.get(SettingsKey.settingsReadReceipt) || false window.storage.get(SettingsKey.settingsReadReceipt) || false
); );
if (window.storage.get(SettingsKey.settingsReadReceipt)) { if (window.storage.get(SettingsKey.settingsReadReceipt)) {
await Promise.all( const timestamps = _.map(read, 'timestamp').filter(t => !!t) as Array<number>;
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => { const receiptMessage = new ReadReceiptMessage({
const timestamps = _.map(receipts, 'timestamp').filter(t => !!t) as Array<number>; timestamp: Date.now(),
const receiptMessage = new ReadReceiptMessage({ timestamps,
timestamp: Date.now(), });
timestamps,
}); const device = new PubKey(this.id);
await getMessageQueue().sendToPubKey(device, receiptMessage);
const device = new PubKey(sender);
await getMessageQueue().sendToPubKey(device, receiptMessage);
})
);
} }
} }
} }

Loading…
Cancel
Save