diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 468027ec8a..33bd46e393 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -17,6 +17,7 @@ struct ChatView: View { @Environment(\.colorScheme) var colorScheme @Environment(\.dismiss) var dismiss @Environment(\.presentationMode) var presentationMode + @Environment(\.scenePhase) var scenePhase @State @ObservedObject var chat: Chat @State private var showChatInfoSheet: Bool = false @State private var showAddMembersSheet: Bool = false @@ -234,7 +235,9 @@ struct ChatView: View { private func initChatView() { let cInfo = chat.chatInfo - if case let .direct(contact) = cInfo { + // This check prevents the call to apiContactInfo after the app is suspended, and the database is closed. + if case .active = scenePhase, + case let .direct(contact) = cInfo { Task { do { let (stats, _) = try await apiContactInfo(chat.chatInfo.apiId) diff --git a/apps/ios/Shared/Views/ChatList/UserPicker.swift b/apps/ios/Shared/Views/ChatList/UserPicker.swift index e115e80f66..922fc84e53 100644 --- a/apps/ios/Shared/Views/ChatList/UserPicker.swift +++ b/apps/ios/Shared/Views/ChatList/UserPicker.swift @@ -92,8 +92,7 @@ struct UserPicker: View { .opacity(userPickerVisible ? 1.0 : 0.0) .onAppear { do { - // This check prevents this after the app is suspended, and the database is closed. - // Unclear why it happens. + // This check prevents the call of listUsers after the app is suspended, and the database is closed. if case .active = scenePhase { m.users = try listUsers() }