Let group update happen on relink
This commit is contained in:
parent
97fe907483
commit
98894ab121
4 changed files with 33 additions and 7 deletions
|
@ -52,6 +52,14 @@
|
||||||
// Make sure poppers are positioned properly
|
// Make sure poppers are positioned properly
|
||||||
window.dispatchEvent(new Event('resize'));
|
window.dispatchEvent(new Event('resize'));
|
||||||
},
|
},
|
||||||
|
unload() {
|
||||||
|
const { lastConversation } = this;
|
||||||
|
if (!lastConversation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastConversation.trigger('unload', 'force unload requested');
|
||||||
|
},
|
||||||
onUnload(conversation) {
|
onUnload(conversation) {
|
||||||
if (this.lastConversation === conversation) {
|
if (this.lastConversation === conversation) {
|
||||||
this.stopListening(this.lastConversation);
|
this.stopListening(this.lastConversation);
|
||||||
|
@ -93,6 +101,12 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Close current opened conversation to reload the group information once
|
||||||
|
// linked.
|
||||||
|
Whisper.events.on('setupAsNewDevice', () => {
|
||||||
|
this.conversation_stack.unload();
|
||||||
|
});
|
||||||
|
|
||||||
if (!options.initialLoadComplete) {
|
if (!options.initialLoadComplete) {
|
||||||
this.appLoadingScreen = new Whisper.AppLoadingScreen();
|
this.appLoadingScreen = new Whisper.AppLoadingScreen();
|
||||||
this.appLoadingScreen.render();
|
this.appLoadingScreen.render();
|
||||||
|
|
16
ts/groups.ts
16
ts/groups.ts
|
@ -22,6 +22,7 @@ import { isStorageWriteFeatureEnabled } from './storage/isFeatureEnabled';
|
||||||
import dataInterface from './sql/Client';
|
import dataInterface from './sql/Client';
|
||||||
import { toWebSafeBase64, fromWebSafeBase64 } from './util/webSafeBase64';
|
import { toWebSafeBase64, fromWebSafeBase64 } from './util/webSafeBase64';
|
||||||
import { assert } from './util/assert';
|
import { assert } from './util/assert';
|
||||||
|
import { isMoreRecentThan } from './util/timestamp';
|
||||||
import {
|
import {
|
||||||
ConversationAttributesType,
|
ConversationAttributesType,
|
||||||
GroupV2MemberType,
|
GroupV2MemberType,
|
||||||
|
@ -2597,6 +2598,8 @@ type MaybeUpdatePropsType = {
|
||||||
dropInitialJoinMessage?: boolean;
|
dropInitialJoinMessage?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const FIVE_MINUTES = 1000 * 60 * 5;
|
||||||
|
|
||||||
export async function waitThenMaybeUpdateGroup(
|
export async function waitThenMaybeUpdateGroup(
|
||||||
options: MaybeUpdatePropsType,
|
options: MaybeUpdatePropsType,
|
||||||
{ viaSync = false } = {}
|
{ viaSync = false } = {}
|
||||||
|
@ -2607,10 +2610,23 @@ export async function waitThenMaybeUpdateGroup(
|
||||||
// Then wait to process all outstanding messages for this conversation
|
// Then wait to process all outstanding messages for this conversation
|
||||||
const { conversation } = options;
|
const { conversation } = options;
|
||||||
|
|
||||||
|
const { lastSuccessfulGroupFetch = 0 } = conversation;
|
||||||
|
|
||||||
|
if (isMoreRecentThan(lastSuccessfulGroupFetch, FIVE_MINUTES)) {
|
||||||
|
const waitTime = lastSuccessfulGroupFetch + FIVE_MINUTES - Date.now();
|
||||||
|
window.log.info(
|
||||||
|
`waitThenMaybeUpdateGroup/${conversation.idForLogging()}: group update ` +
|
||||||
|
`was fetched recently, skipping for ${waitTime}ms`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await conversation.queueJob(async () => {
|
await conversation.queueJob(async () => {
|
||||||
try {
|
try {
|
||||||
// And finally try to update the group
|
// And finally try to update the group
|
||||||
await maybeUpdateGroup(options, { viaSync });
|
await maybeUpdateGroup(options, { viaSync });
|
||||||
|
|
||||||
|
conversation.lastSuccessfulGroupFetch = Date.now();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.log.error(
|
window.log.error(
|
||||||
`waitThenMaybeUpdateGroup/${conversation.idForLogging()}: maybeUpdateGroup failure:`,
|
`waitThenMaybeUpdateGroup/${conversation.idForLogging()}: maybeUpdateGroup failure:`,
|
||||||
|
|
|
@ -150,6 +150,8 @@ export class ConversationModel extends window.Backbone
|
||||||
|
|
||||||
intlCollator = new Intl.Collator(undefined, { sensitivity: 'base' });
|
intlCollator = new Intl.Collator(undefined, { sensitivity: 'base' });
|
||||||
|
|
||||||
|
lastSuccessfulGroupFetch?: number;
|
||||||
|
|
||||||
private cachedLatestGroupCallEraId?: string;
|
private cachedLatestGroupCallEraId?: string;
|
||||||
|
|
||||||
private cachedIdenticon?: CachedIdenticon;
|
private cachedIdenticon?: CachedIdenticon;
|
||||||
|
|
|
@ -391,12 +391,6 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
this.model.updateSharedGroups.bind(this.model),
|
this.model.updateSharedGroups.bind(this.model),
|
||||||
FIVE_MINUTES
|
FIVE_MINUTES
|
||||||
);
|
);
|
||||||
this.model.throttledFetchLatestGroupV2Data =
|
|
||||||
this.model.throttledFetchLatestGroupV2Data ||
|
|
||||||
window._.throttle(
|
|
||||||
this.model.fetchLatestGroupV2Data.bind(this.model),
|
|
||||||
FIVE_MINUTES
|
|
||||||
);
|
|
||||||
this.model.throttledMaybeMigrateV1Group =
|
this.model.throttledMaybeMigrateV1Group =
|
||||||
this.model.throttledMaybeMigrateV1Group ||
|
this.model.throttledMaybeMigrateV1Group ||
|
||||||
window._.throttle(
|
window._.throttle(
|
||||||
|
@ -2181,7 +2175,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
this.setQuoteMessage(quotedMessageId);
|
this.setQuoteMessage(quotedMessageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.throttledFetchLatestGroupV2Data();
|
this.model.fetchLatestGroupV2Data();
|
||||||
this.model.throttledMaybeMigrateV1Group();
|
this.model.throttledMaybeMigrateV1Group();
|
||||||
|
|
||||||
const statusPromise = this.model.throttledGetProfiles();
|
const statusPromise = this.model.throttledGetProfiles();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue