Skip to content

Commit

Permalink
Delete all NSUserActivities when account is logging out
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Behrens <[email protected]>
  • Loading branch information
kloenk committed Sep 27, 2021
1 parent 91d107a commit 1b9c15d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Riot/Managers/Activities/UserActivityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class UserActivityService: NSObject {
super.init()

NotificationCenter.default.addObserver(self, selector: #selector(didLeaveRoom(_:)), name: .mxSessionDidLeaveRoom, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didLogOut(_:)), name: .mxkAccountManagerDidRemoveAccount, object: nil)
}

// MARK: - Public
Expand Down Expand Up @@ -92,7 +93,10 @@ class UserActivityService: NSObject {

func didLeaveRoom(_ notification: Notification) {
guard let roomId = notification.userInfo?[kMXSessionNotificationRoomIdKey] as? String else { return }
// TODO: Remove the room from spotlight
NSUserActivity.deleteSavedUserActivities(withPersistentIdentifiers: [roomId], completionHandler: { })
}

func didLogOut(_ notification: Notification) {
NSUserActivity.deleteAllSavedUserActivities(completionHandler: { })
}
}

0 comments on commit 1b9c15d

Please sign in to comment.