prevent disappearing message affecting the order of conversations

This commit is contained in:
ryanzhao 2021-10-01 16:29:02 +10:00
parent 49688c0a2d
commit ceb88f3d00
3 changed files with 6 additions and 9 deletions

View File

@ -278,15 +278,8 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup"
TSThread *thread1 = (TSThread *)object1;
TSThread *thread2 = (TSThread *)object2;
if ([group isEqualToString:TSArchiveGroup] || [group isEqualToString:TSInboxGroup]) {
TSInteraction *_Nullable lastInteractionForInbox1 =
[thread1 lastInteractionForInboxWithTransaction:transaction];
NSDate *date1 = lastInteractionForInbox1 ? lastInteractionForInbox1.receivedAtDate : thread1.creationDate;
TSInteraction *_Nullable lastInteractionForInbox2 =
[thread2 lastInteractionForInboxWithTransaction:transaction];
NSDate *date2 = lastInteractionForInbox2 ? lastInteractionForInbox2.receivedAtDate : thread2.creationDate;
NSDate *date1 = thread1.lastInteractionDate ?: thread1.creationDate;
NSDate *date2 = thread2.lastInteractionDate ?: thread2.creationDate;
return [date1 compare:date2];
}

View File

@ -18,6 +18,7 @@ BOOL IsNoteToSelfEnabled(void);
@property (nonatomic) BOOL shouldBeVisible;
@property (nonatomic, readonly) NSDate *creationDate;
@property (nonatomic, readonly, nullable) NSDate *lastInteractionDate;
@property (nonatomic, readonly) TSInteraction *lastInteraction;
@property (atomic, readonly) BOOL isMuted;
@property (atomic, readonly, nullable) NSDate *mutedUntilDate;

View File

@ -21,6 +21,7 @@ BOOL IsNoteToSelfEnabled(void)
@interface TSThread ()
@property (nonatomic) NSDate *creationDate;
@property (nonatomic, nullable) NSDate *lastInteractionDate;
@property (nonatomic, nullable) NSNumber *archivedAsOfMessageSortId;
@property (nonatomic, copy, nullable) NSString *messageDraft;
@property (atomic, nullable) NSDate *mutedUntilDate;
@ -355,6 +356,8 @@ BOOL IsNoteToSelfEnabled(void)
if (![self.class shouldInteractionAppearInInbox:lastMessage]) {
return;
}
_lastInteractionDate = lastMessage.receivedAtDate;
if (!self.shouldBeVisible) {
self.shouldBeVisible = YES;