@@ -1470,7 +1470,9 @@ export class ConversationModel extends Model<ConversationAttributes> {
1470
1470
}
1471
1471
}
1472
1472
1473
- private shouldApplyPrivateProfileUpdate ( newProfile : SetSessionProfileDetails ) {
1473
+ private shouldApplyPrivateProfileUpdate < T extends SetSessionProfileDetails > (
1474
+ newProfile : SetSessionProfileDetails
1475
+ ) : newProfile is Extract < T , { profileUpdatedAtSeconds : number } > {
1474
1476
if ( isSetProfileWithUpdatedAtSeconds ( newProfile ) ) {
1475
1477
const ts = new Timestamp ( { value : newProfile . profileUpdatedAtSeconds } ) ;
1476
1478
return this . getProfileUpdatedSeconds ( ) < ts . seconds ( ) ;
@@ -1500,6 +1502,10 @@ export class ConversationModel extends Model<ConversationAttributes> {
1500
1502
this . set ( {
1501
1503
displayNameInProfile : newProfile . displayName ,
1502
1504
} ) ;
1505
+ // name has changed, also apply the new profileUpdatedAtSeconds timestamp
1506
+ if ( isSetProfileWithUpdatedAtSeconds ( newProfile ) ) {
1507
+ this . set ( { profileUpdatedSeconds : newProfile . profileUpdatedAtSeconds } ) ;
1508
+ }
1503
1509
nameChanged = true ;
1504
1510
}
1505
1511
const type = newProfile . type ;
@@ -1533,9 +1539,13 @@ export class ConversationModel extends Model<ConversationAttributes> {
1533
1539
fallbackAvatarInProfile : undefined ,
1534
1540
} ) ;
1535
1541
avatarChanged = true ;
1542
+ // avatar has changed, also apply the new profileUpdatedAtSeconds timestamp
1543
+ if ( isSetProfileWithUpdatedAtSeconds ( newProfile ) ) {
1544
+ this . set ( { profileUpdatedSeconds : newProfile . profileUpdatedAtSeconds } ) ;
1545
+ }
1536
1546
}
1537
1547
}
1538
- if ( avatarChanged ) {
1548
+ if ( avatarChanged || nameChanged ) {
1539
1549
await this . commit ( ) ;
1540
1550
}
1541
1551
return { nameChanged, avatarNeedsDownload : false , avatarChanged } ;
@@ -1562,6 +1572,10 @@ export class ConversationModel extends Model<ConversationAttributes> {
1562
1572
}
1563
1573
this . set ( { avatarPointer : newProfile . avatarPointer , profileKey : newProfileKeyHex } ) ;
1564
1574
1575
+ // avatar has changed, also apply the new profileUpdatedAtSeconds timestamp
1576
+ if ( isSetProfileWithUpdatedAtSeconds ( newProfile ) ) {
1577
+ this . set ( { profileUpdatedSeconds : newProfile . profileUpdatedAtSeconds } ) ;
1578
+ }
1565
1579
await this . commit ( ) ;
1566
1580
1567
1581
return { nameChanged, avatarNeedsDownload : hasAvatarInNewProfile , avatarChanged : true } ;
@@ -1591,6 +1605,9 @@ export class ConversationModel extends Model<ConversationAttributes> {
1591
1605
return { nameChanged, avatarChanged : false , avatarNeedsDownload : false } ;
1592
1606
}
1593
1607
1608
+ // avatar has changed, but we are only dealing with the downloaded part of it here
1609
+ // so this actually is not a profile update change. Nothing to do, as the newProfile type suggests
1610
+
1594
1611
this . set ( {
1595
1612
avatarPointer : newProfile . avatarPointer ,
1596
1613
avatarInProfile : newProfile . avatarPath ,
0 commit comments