Skip to content

Commit 8f863aa

Browse files
Merge pull request #1921 from session-foundation/fix-delete-group-crash
Fix crashes when leaving a stuck state group
2 parents 2685d96 + b0658c0 commit 8f863aa

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

app/src/main/java/org/thoughtcrime/securesms/groups/GroupLeavingWorker.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,24 @@ class GroupLeavingWorker @AssistedInject constructor(
140140

141141
// We now have an admin option to leave group so we need a way of Deleting the group
142142
// even if there are more admins
143-
if (weAreTheOnlyAdmin || deleteGroup) {
144-
configFactory.withMutableGroupConfigs(groupId) { configs ->
145-
configs.groupInfo.destroyGroup()
143+
if ((weAreTheOnlyAdmin || deleteGroup)) {
144+
try {
145+
configFactory.withMutableGroupConfigs(groupId) { configs ->
146+
configs.groupInfo.destroyGroup()
147+
}
148+
149+
// Must wait until the config is pushed, otherwise if we go through the rest
150+
// of the code it will destroy the conversation, destroying the necessary configs
151+
// along the way, we won't be able to push the "destroyed" state anymore.
152+
configFactory.waitUntilGroupConfigsPushed(groupId, timeoutMills = 0L)
153+
} catch (e: CancellationException) {
154+
throw e
155+
} catch (e: Throwable) {
156+
// If the destruction of group can't be done, there's nothing
157+
// else we can do. So we will proceed with the rest where
158+
// we remove the group entry from the database.
159+
Log.e(TAG, "Error while destroying group $groupId. Proceeding...", e)
146160
}
147-
148-
// Must wait until the config is pushed, otherwise if we go through the rest
149-
// of the code it will destroy the conversation, destroying the necessary configs
150-
// along the way, we won't be able to push the "destroyed" state anymore.
151-
configFactory.waitUntilGroupConfigsPushed(groupId, timeoutMills = 0L)
152161
}
153162
}
154163

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ kotlinVersion = "2.3.0"
2929
kryoVersion = "5.6.2"
3030
kspVersion = "2.3.3"
3131
legacySupportV13Version = "1.0.0"
32-
libsessionUtilAndroidVersion = "1.1.0"
32+
libsessionUtilAndroidVersion = "1.1.0-5-gb9061a4"
3333
media3ExoplayerVersion = "1.8.0"
3434
mockitoCoreVersion = "5.21.0"
3535
navVersion = "2.9.6"

0 commit comments

Comments
 (0)