prevent disappearing message affecting the order of conversations
This commit is contained in:
parent
49688c0a2d
commit
ceb88f3d00
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
@ -356,6 +357,8 @@ BOOL IsNoteToSelfEnabled(void)
|
|||
return;
|
||||
}
|
||||
|
||||
_lastInteractionDate = lastMessage.receivedAtDate;
|
||||
|
||||
if (!self.shouldBeVisible) {
|
||||
self.shouldBeVisible = YES;
|
||||
[self saveWithTransaction:transaction];
|
||||
|
|
Loading…
Reference in New Issue