Add savingAccountsEnabled property to MXKAccountManager

This commit is contained in:
ismailgulek
2022-06-06 16:15:32 +03:00
parent 2176bab242
commit 468f1e1c64
2 changed files with 12 additions and 3 deletions
@@ -48,6 +48,9 @@ extern NSString *const MXKAccountManagerDataType;
*/
@interface MXKAccountManager : NSObject
/// Flag indicating that saving accounts enabled. Defaults to `YES`.
@property (nonatomic, assign, getter=isSavingAccountsEnabled) BOOL savingAccountsEnabled;
/**
The class of store used to open matrix session for the accounts. This class must be conformed to MXStore protocol.
By default this class is MXFileStore.
@@ -72,6 +72,7 @@ NSString *const MXKAccountManagerDataType = @"org.matrix.kit.MXKAccountManagerDa
{
_storeClass = [MXFileStore class];
_dehydrationService = [MXDehydrationService new];
_savingAccountsEnabled = YES;
// Migrate old account file to new format
[self migrateAccounts];
@@ -108,10 +109,15 @@ NSString *const MXKAccountManagerDataType = @"org.matrix.kit.MXKAccountManagerDa
#pragma clang diagnostic ignored "-Wdeprecated"
- (void)saveAccounts
{
NSDate *startDate = [NSDate date];
MXLogDebug(@"[MXKAccountManager] saveAccounts...");
if (!self.isSavingAccountsEnabled)
{
MXLogDebug(@"[MXKAccountManager] saveAccounts: saving disabled.");
return;
}
NSDate *startDate = [NSDate date];
NSMutableData *data = [NSMutableData data];
NSKeyedArchiver *encoder = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];