@@ -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
0 commit comments