mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/hideThreadsVsDisappearingMessages' into hotfix/2.15.2
This commit is contained in:
commit
639fcac211
3 changed files with 17 additions and 6 deletions
|
@ -16,6 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface TSThread : TSYapDatabaseObject
|
||||
|
||||
// YES IFF this thread has ever had a message.
|
||||
@property (nonatomic) BOOL hasEverHadMessage;
|
||||
|
||||
/**
|
||||
* Whether the object is a group thread or not.
|
||||
*
|
||||
|
|
|
@ -321,6 +321,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return;
|
||||
}
|
||||
|
||||
self.hasEverHadMessage = YES;
|
||||
|
||||
NSDate *lastMessageDate = [lastMessage dateForSorting];
|
||||
if (!_lastMessageDate || [lastMessageDate timeIntervalSinceDate:self.lastMessageDate] > 0) {
|
||||
_lastMessageDate = lastMessageDate;
|
||||
|
|
|
@ -224,11 +224,17 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
|
||||
TSThread *thread = (TSThread *)object;
|
||||
|
||||
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSMessageDatabaseViewExtensionName];
|
||||
OWSAssert(viewTransaction);
|
||||
NSUInteger threadMessageCount = [viewTransaction numberOfItemsInGroup:thread.uniqueId];
|
||||
if (threadMessageCount < 1) {
|
||||
return nil;
|
||||
if (thread.isGroupThread) {
|
||||
// Do nothing; we never hide group threads.
|
||||
} else if (thread.hasEverHadMessage) {
|
||||
// Do nothing; we never hide threads that have ever had a message.
|
||||
} else {
|
||||
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSMessageDatabaseViewExtensionName];
|
||||
OWSAssert(viewTransaction);
|
||||
NSUInteger threadMessageCount = [viewTransaction numberOfItemsInGroup:thread.uniqueId];
|
||||
if (threadMessageCount < 1) {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (thread.archivalDate) {
|
||||
|
@ -248,7 +254,7 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
[[YapWhitelistBlacklist alloc] initWithWhitelist:[NSSet setWithObject:[TSThread collection]]];
|
||||
|
||||
YapDatabaseView *databaseView =
|
||||
[[YapDatabaseView alloc] initWithGrouping:viewGrouping sorting:viewSorting versionTag:@"2" options:options];
|
||||
[[YapDatabaseView alloc] initWithGrouping:viewGrouping sorting:viewSorting versionTag:@"3" options:options];
|
||||
|
||||
[[TSStorageManager sharedManager].database registerExtension:databaseView
|
||||
withName:TSThreadDatabaseViewExtensionName];
|
||||
|
|
Loading…
Reference in a new issue