Skip to content

Commit dda6e90

Browse files
committed
Fix crashes when leaving a stuck state group
1 parent d8fac66 commit dda6e90

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.api.server.execute
3535
import org.thoughtcrime.securesms.database.Storage
3636
import org.thoughtcrime.securesms.dependencies.ConfigFactory
3737
import org.thoughtcrime.securesms.notifications.PushUnregisterApi
38+
import kotlin.jvm.Throws
3839

3940
@HiltWorker
4041
class GroupLeavingWorker @AssistedInject constructor(
@@ -140,15 +141,24 @@ class GroupLeavingWorker @AssistedInject constructor(
140141

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

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)