Skip to content

Commit ae52d4c

Browse files
committed
Fix crash in the setting when enabling/disabling integration manager and there is no network.
1 parent 8433e22 commit ae52d4c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerC
7171
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
7272
import org.matrix.android.sdk.flow.flow
7373
import org.matrix.android.sdk.flow.unwrap
74+
import timber.log.Timber
7475
import java.io.File
7576
import java.net.URL
7677
import java.util.UUID
@@ -265,7 +266,17 @@ class VectorSettingsGeneralFragment :
265266
// Disable it while updating the state, will be re-enabled by the account data listener.
266267
it.isEnabled = false
267268
lifecycleScope.launch {
268-
session.integrationManagerService().setIntegrationEnabled(newValue as Boolean)
269+
try {
270+
session.integrationManagerService().setIntegrationEnabled(newValue as Boolean)
271+
} catch (failure: Throwable) {
272+
Timber.e(failure, "Failed to update integration manager state")
273+
activity?.let { activity ->
274+
Toast.makeText(activity, errorFormatter.toHumanReadable(failure), Toast.LENGTH_SHORT).show()
275+
}
276+
// Restore the previous state
277+
it.isChecked = !it.isChecked
278+
it.isEnabled = true
279+
}
269280
}
270281
true
271282
}

0 commit comments

Comments
 (0)