Merge pull request #4802 from vector-im/ismail/4801_clear_cache_spinner

Wait for sync response when clearing cache
This commit is contained in:
ismailgulek 2021-09-08 15:22:20 +03:00 committed by GitHub
commit 53aeb8c378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 20 deletions

View file

@ -241,21 +241,6 @@ UINavigationControllerDelegate
*/
- (BOOL)handleUniversalLinkURL:(NSURL*)universalLinkURL;
#pragma mark - Jitsi call
/**
Open the Jitsi view controller from a widget.
@param jitsiWidget the jitsi widget.
@param video to indicate voice or video call.
*/
- (void)displayJitsiViewControllerWithWidget:(Widget*)jitsiWidget andVideo:(BOOL)video;
/**
The current Jitsi view controller being displayed.
*/
@property (nonatomic, readonly) JitsiViewController *jitsiViewController;
#pragma mark - App version management
/**

View file

@ -234,6 +234,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
*/
@property (nonatomic, assign, getter=isRoomListDataReady) BOOL roomListDataReady;
/**
Flag to indicate whether a cache clear is being performed.
*/
@property (nonatomic, assign, getter=isClearingCache) BOOL clearingCache;
@end
@implementation LegacyAppDelegate
@ -378,6 +383,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
MXLogDebug(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@", @([application isProtectedDataAvailable]));
_configuration = [AppConfiguration new];
self.clearingCache = NO;
// Log app information
NSString *appDisplayName = self.appInfo.displayName;
@ -2045,6 +2051,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
if (clearCache)
{
self.clearingCache = YES;
[self clearCache];
}
}
@ -2233,6 +2240,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
{
case MXSessionStateClosed:
case MXSessionStateInitialised:
case MXSessionStateBackgroundSyncInProgress:
self.roomListDataReady = NO;
isLaunching = YES;
break;
case MXSessionStateStoreDataReady:
@ -2245,6 +2254,10 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
[mainSession.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
}
break;
case MXSessionStateRunning:
self.clearingCache = NO;
isLaunching = NO;
break;
default:
isLaunching = NO;
break;
@ -2260,6 +2273,12 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
return;
}
if (self.isClearingCache)
{
// wait for another session state change to check room list data is ready
return;
}
[self ensureRoomListDataReadyWithCompletion:^{
[self hideLaunchAnimation];

View file

@ -977,11 +977,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
if (dataSource.state == MXKDataSourceStateReady)
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[[NSNotificationCenter defaultCenter] postNotificationName:RecentsViewControllerDataReadyNotification
object:self];
});
[[NSNotificationCenter defaultCenter] postNotificationName:RecentsViewControllerDataReadyNotification
object:self];
}
}

1
changelog.d/4801.bugfix Normal file
View file

@ -0,0 +1 @@
AppDelegate: Wait for sync response when clearing cache.