Skip to content
Snippets Groups Projects
Commit 22c94d14 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

presence: unsubscribe when app is in background

Change-Id: Ie15efebd03ea57e1ba9b7c33c406ac4e940a75ae
parent 99e288b9
No related branches found
No related tags found
No related merge requests found
...@@ -240,16 +240,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD ...@@ -240,16 +240,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
} }
func reloadDataFor(account: AccountModel) { func reloadDataFor(account: AccountModel) {
self.contactsService.loadContacts(withAccount: account) let state = UIApplication.shared.applicationState
self.contactsService.loadContactRequests(withAccount: account.id) if state == .active {
self.presenceService.subscribeBuddies(withAccount: account.id, withContacts: self.contactsService.contacts.value, subscribe: true) self.contactsService.loadContacts(withAccount: account)
self.conversationManager? self.contactsService.loadContactRequests(withAccount: account.id)
.prepareConversationsForAccount(accountId: account.id) self.presenceService.subscribeBuddies(withAccount: account.id, withContacts: self.contactsService.contacts.value, subscribe: true)
self.conversationManager?
.prepareConversationsForAccount(accountId: account.id)
}
} }
func applicationDidEnterBackground(_ application: UIApplication) { func applicationDidEnterBackground(_ application: UIApplication) {
self.log.warning("entering background") self.log.warning("entering background")
self.callService.muteCurrentCallVideoVideo( mute: true) self.callService.muteCurrentCallVideoVideo( mute: true)
guard let account = self.accountService.currentAccount else { return }
self.presenceService.subscribeBuddies(withAccount: account.id, withContacts: self.contactsService.contacts.value, subscribe: false)
} }
func applicationWillEnterForeground(_ application: UIApplication) { func applicationWillEnterForeground(_ application: UIApplication) {
...@@ -257,6 +262,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD ...@@ -257,6 +262,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
self.daemonService.connectivityChanged() self.daemonService.connectivityChanged()
self.updateNotificationAvailability() self.updateNotificationAvailability()
self.callService.muteCurrentCallVideoVideo( mute: false) self.callService.muteCurrentCallVideoVideo( mute: false)
guard let account = self.accountService.currentAccount else { return }
self.presenceService.subscribeBuddies(withAccount: account.id, withContacts: self.contactsService.contacts.value, subscribe: true)
} }
func applicationWillTerminate(_ application: UIApplication) { func applicationWillTerminate(_ application: UIApplication) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment