From 95de471754abc3065c530c84bcf822af01fe90ea Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:05:35 +0400 Subject: [PATCH] desktop: fix app without user crashing when trying to get subscription data (#4551) --- .../chat/simplex/common/views/chatlist/ChatListView.kt | 10 ++++++---- .../common/views/chatlist/ServersSummaryView.kt | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index 1032b59474..29b2882cbb 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -291,10 +291,12 @@ fun SubscriptionStatusIndicator(click: (() -> Unit)) { val scope = rememberCoroutineScope() suspend fun setSubsTotal() { - val r = chatModel.controller.getAgentSubsTotal(chatModel.remoteHostId()) - if (r != null) { - subs = r.first - hasSess = r.second + if (chatModel.currentUser.value != null) { + val r = chatModel.controller.getAgentSubsTotal(chatModel.remoteHostId()) + if (r != null) { + subs = r.first + hasSess = r.second + } } } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt index 8621c73ef3..4bb5474fa6 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ServersSummaryView.kt @@ -719,7 +719,9 @@ fun ModalData.ServersSummaryView(rh: RemoteHostInfo?, serversSummary: MutableSta val scope = rememberCoroutineScope() suspend fun setServersSummary() { - serversSummary.value = chatModel.controller.getAgentServersSummary(chatModel.remoteHostId()) + if (chatModel.currentUser.value != null) { + serversSummary.value = chatModel.controller.getAgentServersSummary(chatModel.remoteHostId()) + } } LaunchedEffect(Unit) {