Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
element-hq/element-ios/issues/4578 - Added transient info storage dic…
Browse files Browse the repository at this point in the history
…tionary on MXKAccount.
  • Loading branch information
stefanceriu committed Jul 20, 2021
1 parent 6f6dbae commit d69c650
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions MatrixKit/Models/Account/MXKAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer
*/
@property (nonatomic, readonly) BOOL pushNotificationServiceIsActive;

/**
Transient information storage.
*/
@property (nonatomic, strong, readonly) NSMutableDictionary<NSString *, id<NSCoding>> *others;

/**
Enable Push notification based on Apple Push Notification Service (APNS).
Expand Down
21 changes: 16 additions & 5 deletions MatrixKit/Models/Account/MXKAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ @interface MXKAccount ()

// Background sync management
MXOnBackgroundSyncDone backgroundSyncDone;
MXOnBackgroundSyncFail backgroundSyncfails;
MXOnBackgroundSyncFail backgroundSyncFails;
NSTimer* backgroundSyncTimer;

// Observe UIApplicationSignificantTimeChangeNotification to refresh MXRoomSummaries on time formatting change.
Expand All @@ -89,6 +89,8 @@ @interface MXKAccount ()
@property (nonatomic, strong) id<MXBackgroundTask> backgroundTask;
@property (nonatomic, strong) id<MXBackgroundTask> backgroundSyncBgTask;

@property (nonatomic, strong) NSMutableDictionary<NSString *, id<NSCoding>> *others;

@end

@implementation MXKAccount
Expand Down Expand Up @@ -614,6 +616,15 @@ - (void)setShowDecryptedContentInNotifications:(BOOL)showDecryptedContentInNotif
[[MXKAccountManager sharedManager] saveAccounts];
}

- (NSMutableDictionary<NSString *, id<NSCoding>> *)others
{
if(_others == nil) {
_others = [NSMutableDictionary dictionary];
}

return _others;
}

#pragma mark - Matrix user's profile

- (void)setUserDisplayName:(NSString*)displayname success:(void (^)(void))success failure:(void (^)(NSError *error))failure
Expand Down Expand Up @@ -1835,9 +1846,9 @@ - (void)onBackgroundSyncDone:(NSError*)error
backgroundSyncTimer = nil;
}

if (backgroundSyncfails && error)
if (backgroundSyncFails && error)
{
backgroundSyncfails(error);
backgroundSyncFails(error);
}

if (backgroundSyncDone && !error)
Expand All @@ -1846,7 +1857,7 @@ - (void)onBackgroundSyncDone:(NSError*)error
}

backgroundSyncDone = nil;
backgroundSyncfails = nil;
backgroundSyncFails = nil;

// End background task
if (self.backgroundSyncBgTask.isRunning)
Expand Down Expand Up @@ -1874,7 +1885,7 @@ - (void)backgroundSync:(unsigned int)timeout success:(void (^)(void))success fai
MXLogDebug(@"[MXKAccount] starts a background Sync");

backgroundSyncDone = success;
backgroundSyncfails = failure;
backgroundSyncFails = failure;

MXWeakify(self);

Expand Down

0 comments on commit d69c650

Please sign in to comment.