mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-05 13:58:40 +00:00
Code cleanup in App
This commit is contained in:
parent
b1f81dbe2f
commit
d600ab8800
1 changed files with 21 additions and 14 deletions
|
@ -68,15 +68,13 @@ struct IceCubesApp: App {
|
||||||
}
|
}
|
||||||
.tint(theme.tintColor)
|
.tint(theme.tintColor)
|
||||||
.onChange(of: appAccountsManager.currentClient) { newClient in
|
.onChange(of: appAccountsManager.currentClient) { newClient in
|
||||||
currentAccount.setClient(client: newClient)
|
setNewClientsInEnv(client: newClient)
|
||||||
watcher.setClient(client: newClient)
|
|
||||||
if newClient.isAuth {
|
if newClient.isAuth {
|
||||||
watcher.watch(stream: .user)
|
watcher.watch(stream: .user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
currentAccount.setClient(client: appAccountsManager.currentClient)
|
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||||
watcher.setClient(client: appAccountsManager.currentClient)
|
|
||||||
}
|
}
|
||||||
.environmentObject(appAccountsManager)
|
.environmentObject(appAccountsManager)
|
||||||
.environmentObject(appAccountsManager.currentClient)
|
.environmentObject(appAccountsManager.currentClient)
|
||||||
|
@ -87,16 +85,25 @@ struct IceCubesApp: App {
|
||||||
.quickLookPreview($quickLook.url, in: quickLook.urls)
|
.quickLookPreview($quickLook.url, in: quickLook.urls)
|
||||||
}
|
}
|
||||||
.onChange(of: scenePhase, perform: { scenePhase in
|
.onChange(of: scenePhase, perform: { scenePhase in
|
||||||
switch scenePhase {
|
handleScenePhase(scenePhase: scenePhase)
|
||||||
case .background:
|
|
||||||
watcher.stopWatching()
|
|
||||||
case .active:
|
|
||||||
watcher.watch(stream: .user)
|
|
||||||
case .inactive:
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 a new issue