Skip to content

Commit 6245cf0

Browse files
committed
fix: allow 0 as avatarProfileTs to be applied
for the transition where not eveyrone has upgraded
1 parent 63c94e1 commit 6245cf0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ts/models/conversation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,19 @@ export class ConversationModel extends Model<ConversationAttributes> {
14741474
newProfile: SetSessionProfileDetails
14751475
): newProfile is Extract<T, { profileUpdatedAtSeconds: number }> {
14761476
if (isSetProfileWithUpdatedAtSeconds(newProfile)) {
1477+
// For the transition period, we need to allow an incoming profile to be applied when
1478+
// the timestamp is not set (defaults to 0).
1479+
if (newProfile.profileUpdatedAtSeconds === 0 && this.getProfileUpdatedSeconds() === 0) {
1480+
window.log.debug(
1481+
`shouldApplyPrivateProfileUpdate for ${ed25519Str(this.id)} incomingSeconds:0 currentSeconds:0. Allowing overwrite`
1482+
);
1483+
return true;
1484+
}
14771485
const ts = new Timestamp({ value: newProfile.profileUpdatedAtSeconds });
1486+
window.log.debug(
1487+
`shouldApplyPrivateProfileUpdate for ${ed25519Str(this.id)} incomingSeconds:${ts.seconds()} currentSeconds:${this.getProfileUpdatedSeconds()} -> ${this.getProfileUpdatedSeconds() < ts.seconds()}`
1488+
);
1489+
14781490
return this.getProfileUpdatedSeconds() < ts.seconds();
14791491
}
14801492
// for non private setProfile calls, we do not need to check the updatedAtSeconds

ts/models/conversationAttributes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ export type WithAvatarPointer = {
233233
};
234234

235235
export type WithProfileUpdatedAtSeconds = {
236+
/**
237+
* 0 is allowed for the transition period (until enough users have migrated to sending their profileUpdatedAtSeconds).
238+
* Allowed as in an incoming message with a lokiProfile updated at 0, will be applied locally, if needed
239+
*/
236240
profileUpdatedAtSeconds: number;
237241
};
238242

0 commit comments

Comments
 (0)