Skip to content

Commit

Permalink
Use workaround for ios bug not properly removing share intentions
Browse files Browse the repository at this point in the history
When removing or disabling a contact, all share intentions for all
contacts on this account should be properly removed to nos provide
dangling share extension in ios' ui.
  • Loading branch information
tmolitor-stud-tu committed Aug 12, 2024
1 parent 77b5642 commit cee3822
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions Monal/Classes/HelperTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void swizzle(Class c, SEL orig, SEL new);
+(void) configureFileProtection:(NSString*) protectionLevel forFile:(NSString*) file;
+(void) configureFileProtectionFor:(NSString*) file;
+(BOOL) isContactBlacklistedForEncryption:(MLContact*) contact;
+(void) removeAllShareInteractionsForAccountNo:(NSNumber*) accountNo;
+(NSDictionary<NSString*, NSString*>*) splitJid:(NSString*) jid;

+(void) scheduleBackgroundTask:(BOOL) force;
Expand Down
8 changes: 8 additions & 0 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,14 @@ +(BOOL) isContactBlacklistedForEncryption:(MLContact*) contact
return blacklisted;
}

+(void) removeAllShareInteractionsForAccountNo:(NSNumber*) accountNo
{
DDLogInfo(@"Removing share interaction for all contacts on account id %@", accountNo);
for(MLContact* contact in [[DataLayer sharedInstance] contactList])
if(contact.accountId.intValue == accountNo.intValue)
[contact removeShareInteractions];
}

+(void) scheduleBackgroundTask:(BOOL) force
{
DDLogInfo(@"Scheduling new BackgroundTask with force=%s...", force ? "yes" : "no");
Expand Down
5 changes: 1 addition & 4 deletions Monal/Classes/MLXMPPManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,7 @@ -(void) removeAccountForAccountNo:(NSNumber*) accountNo
[self disconnectAccount:accountNo withExplicitLogout:YES];
[[DataLayer sharedInstance] removeAccount:accountNo];
[SAMKeychain deletePasswordForService:kMonalKeychainName account:accountNo.stringValue];
[INInteraction deleteAllInteractionsWithCompletion:^(NSError* error) {
if(error != nil)
DDLogError(@"Could not delete all SiriKit interactions: %@", error);
}];
[HelperTools removeAllShareInteractionsForAccountNo:accountNo];
// trigger UI removal
[[MLNotificationQueue currentQueue] postNotificationName:kMonalRefresh object:nil userInfo:nil];
}
Expand Down
10 changes: 2 additions & 8 deletions Monal/Classes/XMPPEdit.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,7 @@ -(IBAction) save:(id) sender
{
DDLogVerbose(@"Making sure newly created account is not connected and deleting all SiriKit interactions: %@", self.accountNo);
[[MLXMPPManager sharedInstance] disconnectAccount:self.accountNo withExplicitLogout:YES];
[INInteraction deleteAllInteractionsWithCompletion:^(NSError* error) {
if(error != nil)
DDLogError(@"Could not delete all SiriKit interactions: %@", error);
}];
[HelperTools removeAllShareInteractionsForAccountNo:self.accountNo];
}
//trigger view updates to make sure enabled/disabled account state propagates to all ui elements
[[MLNotificationQueue currentQueue] postNotificationName:kMonalRefresh object:nil userInfo:nil];
Expand All @@ -400,10 +397,7 @@ -(IBAction) save:(id) sender
{
DDLogVerbose(@"Account is not enabled anymore, deleting all SiriKit interactions and making sure it's disconnected: %@", self.accountNo);
[[MLXMPPManager sharedInstance] disconnectAccount:self.accountNo withExplicitLogout:YES];
[INInteraction deleteAllInteractionsWithCompletion:^(NSError* error) {
if(error != nil)
DDLogError(@"Could not delete all SiriKit interactions: %@", error);
}];
[HelperTools removeAllShareInteractionsForAccountNo:self.accountNo];
}
//this case makes sure we recreate a completely new account instance below (using our new settings) if the account details changed
else if(self.detailsChanged)
Expand Down

0 comments on commit cee3822

Please sign in to comment.