File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ const doAppStartUp = async () => {
164
164
// Schedule all avatarMigrateJobs in some time to let anything incoming from the network be handled first
165
165
void AvatarMigrate . scheduleAllAvatarMigrateJobs ( ) ;
166
166
} , 1 * DURATION . MINUTES ) ;
167
+
168
+ void regenerateLastMessagesGroupsCommunities ( ) ;
167
169
} ;
168
170
169
171
function useUpdateBadgeCount ( ) {
@@ -195,6 +197,24 @@ function useDebugThemeSwitch() {
195
197
) ;
196
198
}
197
199
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
+
198
218
/**
199
219
* ActionsPanel is the far left banner (not the left pane).
200
220
* The panel with buttons to switch between the message/contact/settings/theme views
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ const latestUserGroupEnvelopeTimestamp = 'latestUserGroupEnvelopeTimestamp';
22
22
const latestUserContactsEnvelopeTimestamp = 'latestUserContactsEnvelopeTimestamp' ;
23
23
const showOnboardingAccountJustCreated = 'showOnboardingAccountJustCreated' ;
24
24
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
+
25
33
export const SettingsKey = {
26
34
settingsReadReceipt,
27
35
settingsTypingIndicator,
@@ -44,6 +52,7 @@ export const SettingsKey = {
44
52
hasFollowSystemThemeEnabled,
45
53
hideRecoveryPassword,
46
54
showOnboardingAccountJustCreated,
55
+ lastMessageGroupsRegenerated,
47
56
} as const ;
48
57
49
58
export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM' ;
Original file line number Diff line number Diff line change @@ -407,6 +407,14 @@ export class MessageModel extends Model<MessageAttributes> {
407
407
) ;
408
408
}
409
409
} ) ;
410
+ if ( this . getConversation ( ) ?. isOpenGroupV2 ( ) || this . getConversation ( ) ?. isClosedGroupV2 ( ) ) {
411
+ const source = this . get ( 'source' ) ;
412
+
413
+ const author = isUsAnySogsFromCache ( source )
414
+ ? tr ( 'you' )
415
+ : ConvoHub . use ( ) . getNicknameOrRealUsernameOrPlaceholder ( source ) ;
416
+ return tr ( 'messageSnippetGroup' , { author, message_snippet : bodyMentionsMappedToNames } ) ;
417
+ }
410
418
return bodyMentionsMappedToNames ;
411
419
}
412
420
You can’t perform that action at this time.
0 commit comments