From 05f8dc6d43f11b8676e6b9f543e0cafc81c2f9e2 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Thu, 22 Jun 2023 14:08:03 +1000 Subject: [PATCH] fix: new community doesn't break persisting config if the .add request fails --- .../java/org/thoughtcrime/securesms/database/Storage.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 513e32a6d1..be2dd0c71b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -551,8 +551,12 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co val groupBaseCommunity = groupInfo.community if (groupBaseCommunity.fullUrl() !in existingJoinUrls) { // add it - val (threadId, _) = OpenGroupManager.add(groupBaseCommunity.baseUrl, groupBaseCommunity.room, groupBaseCommunity.pubKeyHex, context) - threadDb.setPinned(threadId, groupInfo.priority == PRIORITY_PINNED) + try { + val (threadId, _) = OpenGroupManager.add(groupBaseCommunity.baseUrl, groupBaseCommunity.room, groupBaseCommunity.pubKeyHex, context) + threadDb.setPinned(threadId, groupInfo.priority == PRIORITY_PINNED) + } catch (e: Exception) { + Log.e("Loki", "Failed to get Open Group Info on syncing config",e) + } } else { val (threadId, _) = existingCommunities.entries.first { (_, v) -> v.joinURL == groupInfo.community.fullUrl() } threadDb.setPinned(threadId, groupInfo.priority == PRIORITY_PINNED)