mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/hideEmptyConversations'
This commit is contained in:
commit
2bd113f140
6 changed files with 38 additions and 20 deletions
|
@ -171,6 +171,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
|
||||
NSString *lastLaunchedAppVersion = AppVersion.instance.lastAppVersion;
|
||||
NSString *lastCompletedLaunchAppVersion = AppVersion.instance.lastCompletedLaunchAppVersion;
|
||||
// Every time we change a database view in such a way that might cause a delay on launch,
|
||||
// we need to bump this constant.
|
||||
//
|
||||
// We added a number of database views in v2.13.0.
|
||||
NSString *kLastVersionWithDatabaseViewChange = @"2.13.0";
|
||||
BOOL mayNeedUpgrade = ([TSAccountManager isRegistered] && lastLaunchedAppVersion
|
||||
|
|
|
@ -528,9 +528,6 @@ typedef enum : NSUInteger {
|
|||
// We need to update the dynamic interactions before we do any layout.
|
||||
[self ensureDynamicInteractions];
|
||||
|
||||
// Triggering modified notification renders "call notification" when leaving full screen call view
|
||||
[self.thread touch];
|
||||
|
||||
[self ensureBannerState];
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
|
|
|
@ -114,6 +114,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[fetchedThread updateWithLastMessage:self transaction:transaction];
|
||||
}
|
||||
|
||||
- (void)removeWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
|
||||
{
|
||||
[super removeWithTransaction:transaction];
|
||||
|
||||
[self touchThreadWithTransaction:transaction];
|
||||
}
|
||||
|
||||
- (BOOL)isDynamicInteraction
|
||||
{
|
||||
return NO;
|
||||
|
|
|
@ -25,6 +25,7 @@ extern NSString *const TSSecondaryDevicesDatabaseViewExtensionName;
|
|||
|
||||
+ (BOOL)hasPendingViewRegistrations;
|
||||
|
||||
// This method must be called _AFTER_ registerThreadInteractionsDatabaseView.
|
||||
+ (void)registerThreadDatabaseView;
|
||||
|
||||
+ (void)registerThreadInteractionsDatabaseView;
|
||||
|
|
|
@ -82,6 +82,7 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
|
||||
YapDatabaseView *existingView = [[TSStorageManager sharedManager].database registeredExtension:viewName];
|
||||
if (existingView) {
|
||||
OWSFail(@"Registered database view twice: %@", viewName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -211,24 +212,33 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
YapDatabaseView *threadView =
|
||||
[[TSStorageManager sharedManager].database registeredExtension:TSThreadDatabaseViewExtensionName];
|
||||
if (threadView) {
|
||||
OWSFail(@"Registered database view twice: %@", TSThreadDatabaseViewExtensionName);
|
||||
return;
|
||||
}
|
||||
|
||||
YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping
|
||||
withObjectBlock:^NSString *(
|
||||
YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) {
|
||||
if ([object isKindOfClass:[TSThread class]]) {
|
||||
TSThread *thread = (TSThread *)object;
|
||||
if (thread.archivalDate) {
|
||||
return ([self threadShouldBeInInbox:thread]) ? TSInboxGroup : TSArchiveGroup;
|
||||
} else if (thread.archivalDate) {
|
||||
return TSArchiveGroup;
|
||||
} else {
|
||||
return TSInboxGroup;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}];
|
||||
YapDatabaseViewGrouping *viewGrouping = [YapDatabaseViewGrouping withObjectBlock:^NSString *(
|
||||
YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object) {
|
||||
if (![object isKindOfClass:[TSThread class]]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TSThread *thread = (TSThread *)object;
|
||||
|
||||
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSMessageDatabaseViewExtensionName];
|
||||
OWSAssert(viewTransaction);
|
||||
NSUInteger threadMessageCount = [viewTransaction numberOfItemsInGroup:thread.uniqueId];
|
||||
if (threadMessageCount < 1) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (thread.archivalDate) {
|
||||
return ([self threadShouldBeInInbox:thread]) ? TSInboxGroup : TSArchiveGroup;
|
||||
} else if (thread.archivalDate) {
|
||||
return TSArchiveGroup;
|
||||
} else {
|
||||
return TSInboxGroup;
|
||||
}
|
||||
}];
|
||||
|
||||
YapDatabaseViewSorting *viewSorting = [self threadSorting];
|
||||
|
||||
|
@ -238,7 +248,7 @@ NSString *const TSSecondaryDevicesDatabaseViewExtensionName = @"TSSecondaryDevic
|
|||
[[YapWhitelistBlacklist alloc] initWithWhitelist:[NSSet setWithObject:[TSThread collection]]];
|
||||
|
||||
YapDatabaseView *databaseView =
|
||||
[[YapDatabaseView alloc] initWithGrouping:viewGrouping sorting:viewSorting versionTag:@"1" options:options];
|
||||
[[YapDatabaseView alloc] initWithGrouping:viewGrouping sorting:viewSorting versionTag:@"2" options:options];
|
||||
|
||||
[[TSStorageManager sharedManager].database registerExtension:databaseView
|
||||
withName:TSThreadDatabaseViewExtensionName];
|
||||
|
|
|
@ -192,8 +192,8 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
|
|||
- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)())safeBlockingMigrationsBlock
|
||||
{
|
||||
// Synchronously register extensions which are essential for views.
|
||||
[TSDatabaseView registerThreadDatabaseView];
|
||||
[TSDatabaseView registerThreadInteractionsDatabaseView];
|
||||
[TSDatabaseView registerThreadDatabaseView];
|
||||
[TSDatabaseView registerUnreadDatabaseView];
|
||||
[self.database registerExtension:[TSDatabaseSecondaryIndexes registerTimeStampIndex] withName:@"idx"];
|
||||
[OWSMessageReceiver syncRegisterDatabaseExtension:self.database];
|
||||
|
|
Loading…
Reference in a new issue