Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

sync on app launch

Prateek Sunal6120e2519cb1
diff --git a/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift b/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
index e5475addb9..8ac92b704d 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/HomeView.swift
@@ -4,17 +4,25 @@ struct HomeView: View {
@EnvironmentObject private var appState: EnsuAppState
@StateObject private var chatModel = ChatViewModel()
@State private var isShowingAuth = false
+ @State private var didTriggerInitialSync = false
var body: some View {
ChatView(viewModel: chatModel, isShowingAuth: $isShowingAuth)
.platformFullScreenCover(isPresented: $isShowingAuth) {
AuthFlowView()
}
+ .task {
+ guard appState.isLoggedIn, !didTriggerInitialSync else { return }
+ didTriggerInitialSync = true
+ chatModel.syncAfterLogin()
+ }
.onChange(of: appState.isLoggedIn) { isLoggedIn in
if isLoggedIn {
isShowingAuth = false
+ didTriggerInitialSync = true
chatModel.syncAfterLogin()
} else {
+ didTriggerInitialSync = false
chatModel.handleLogout()
}
}