mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 21:42:03 +01:00
Code cleanup in App
This commit is contained in:
parent
b1f81dbe2f
commit
d600ab8800
@ -68,15 +68,13 @@ struct IceCubesApp: App {
|
||||
}
|
||||
.tint(theme.tintColor)
|
||||
.onChange(of: appAccountsManager.currentClient) { newClient in
|
||||
currentAccount.setClient(client: newClient)
|
||||
watcher.setClient(client: newClient)
|
||||
setNewClientsInEnv(client: newClient)
|
||||
if newClient.isAuth {
|
||||
watcher.watch(stream: .user)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
currentAccount.setClient(client: appAccountsManager.currentClient)
|
||||
watcher.setClient(client: appAccountsManager.currentClient)
|
||||
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||
}
|
||||
.environmentObject(appAccountsManager)
|
||||
.environmentObject(appAccountsManager.currentClient)
|
||||
@ -87,16 +85,25 @@ struct IceCubesApp: App {
|
||||
.quickLookPreview($quickLook.url, in: quickLook.urls)
|
||||
}
|
||||
.onChange(of: scenePhase, perform: { scenePhase in
|
||||
switch scenePhase {
|
||||
case .background:
|
||||
watcher.stopWatching()
|
||||
case .active:
|
||||
watcher.watch(stream: .user)
|
||||
case .inactive:
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
handleScenePhase(scenePhase: scenePhase)
|
||||
})
|
||||
}
|
||||
|
||||
private func setNewClientsInEnv(client: Client) {
|
||||
currentAccount.setClient(client: client)
|
||||
watcher.setClient(client: client)
|
||||
}
|
||||
|
||||
private func handleScenePhase(scenePhase: ScenePhase) {
|
||||
switch scenePhase {
|
||||
case .background:
|
||||
watcher.stopWatching()
|
||||
case .active:
|
||||
watcher.watch(stream: .user)
|
||||
case .inactive:
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user