Skip to content

Commit eddf50a

Browse files
committed
fix: regenerate existing group/communities last msg
1 parent 0b6a092 commit eddf50a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

ts/components/leftpane/ActionsPanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ const doAppStartUp = async () => {
164164
// Schedule all avatarMigrateJobs in some time to let anything incoming from the network be handled first
165165
void AvatarMigrate.scheduleAllAvatarMigrateJobs();
166166
}, 1 * DURATION.MINUTES);
167+
168+
void regenerateLastMessagesGroupsCommunities();
167169
};
168170

169171
function useUpdateBadgeCount() {
@@ -195,6 +197,24 @@ function useDebugThemeSwitch() {
195197
);
196198
}
197199

200+
/**
201+
* We only need to regenerate the last message of groups/communities once,
202+
* and we can remove it in a few months safely
203+
*/
204+
async function regenerateLastMessagesGroupsCommunities() {
205+
if (Storage.getBoolOr(SettingsKey.lastMessageGroupsRegenerated, false)) {
206+
return; // already regenerated once
207+
}
208+
209+
ConvoHub.use()
210+
.getConversations()
211+
.filter(m => m.isClosedGroupV2() || m.isPublic())
212+
.forEach(m => {
213+
m.updateLastMessage();
214+
});
215+
await Storage.put(SettingsKey.lastMessageGroupsRegenerated, true);
216+
}
217+
198218
/**
199219
* ActionsPanel is the far left banner (not the left pane).
200220
* The panel with buttons to switch between the message/contact/settings/theme views

ts/data/settings-key.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const latestUserGroupEnvelopeTimestamp = 'latestUserGroupEnvelopeTimestamp';
2222
const latestUserContactsEnvelopeTimestamp = 'latestUserContactsEnvelopeTimestamp';
2323
const showOnboardingAccountJustCreated = 'showOnboardingAccountJustCreated';
2424

25+
/**
26+
* When we added the author of a message in groups in the last message,
27+
* we also had to regenerate the existing last messages.
28+
* We only need to do this once, and we can remove it in a few months safely :tm:
29+
*
30+
*/
31+
const lastMessageGroupsRegenerated = 'lastMessageGroupsRegenerated';
32+
2533
export const SettingsKey = {
2634
settingsReadReceipt,
2735
settingsTypingIndicator,
@@ -44,6 +52,7 @@ export const SettingsKey = {
4452
hasFollowSystemThemeEnabled,
4553
hideRecoveryPassword,
4654
showOnboardingAccountJustCreated,
55+
lastMessageGroupsRegenerated,
4756
} as const;
4857

4958
export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM';

0 commit comments

Comments
 (0)