fix: new community doesn't break persisting config if the .add request fails

This commit is contained in:
0x330a 2023-06-22 14:08:03 +10:00
parent f19be7d6ab
commit 05f8dc6d43
No known key found for this signature in database
GPG Key ID: 267811D6E6A2698C

View File

@ -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)