@@ -1288,15 +1288,15 @@ class ConversationsListActivity : BaseActivity() {
12881288 @SuppressLint(" StringFormatInvalid" )
12891289 private fun showLeaveConversationSnackbar (conversation : ConversationModel ) {
12901290 val token = conversation.token ? : return
1291- conversationsListViewModel.markConversationPendingLeave (token)
1291+ conversationsListViewModel.markConversationPendingRemoval (token)
12921292 lifecycleScope.launch {
12931293 val result = snackbarHostState.showSnackbar(
12941294 message = String .format(resources.getString(R .string.left_conversation), conversation.displayName),
12951295 actionLabel = getString(R .string.nc_undo),
12961296 duration = SnackbarDuration .Long
12971297 )
12981298 when (result) {
1299- SnackbarResult .ActionPerformed -> conversationsListViewModel.clearConversationPendingLeave (token)
1299+ SnackbarResult .ActionPerformed -> conversationsListViewModel.clearConversationPendingRemoval (token)
13001300 SnackbarResult .Dismissed -> leaveConversation(conversation)
13011301 }
13021302 }
@@ -1324,12 +1324,12 @@ class ConversationsListActivity : BaseActivity() {
13241324 resources.getString(R .string.nc_shortcut_conversation_deleted)
13251325 )
13261326 }
1327- conversationsListViewModel.clearConversationPendingLeave (token)
1327+ conversationsListViewModel.clearConversationPendingRemoval (token)
13281328 fetchRooms()
13291329 }
13301330 WorkInfo .State .FAILED -> {
13311331 logger.e(TAG , " LeaveConversationWorker failed for token $token " )
1332- conversationsListViewModel.clearConversationPendingLeave (token)
1332+ conversationsListViewModel.clearConversationPendingRemoval (token)
13331333 showSnackbar(resources.getString(R .string.nc_common_error_sorry))
13341334 }
13351335 else -> {}
@@ -1346,6 +1346,7 @@ class ConversationsListActivity : BaseActivity() {
13461346 .setTitle(R .string.nc_delete_call)
13471347 .setMessage(R .string.nc_delete_conversation_more)
13481348 .setPositiveButton(R .string.nc_delete) { _, _ ->
1349+ conversation.token?.let { conversationsListViewModel.markConversationPendingRemoval(it) }
13491350 deleteConversation(conversation)
13501351 }
13511352 .setNegativeButton(R .string.nc_cancel) { _, _ ->
@@ -1567,32 +1568,40 @@ class ConversationsListActivity : BaseActivity() {
15671568
15681569 WorkManager .getInstance(context).getWorkInfoByIdLiveData(deleteConversationWorker.id)
15691570 .observeForever { workInfo: WorkInfo ? ->
1570- if (workInfo != null ) {
1571- when (workInfo.state) {
1572- WorkInfo .State .SUCCEEDED -> {
1573- currentUser.id?.let { userId ->
1574- ShortcutManagerHelper .disableConversationShortcut(
1575- context,
1576- conversation.token,
1577- userId,
1578- context.resources.getString(R .string.nc_shortcut_conversation_deleted)
1579- )
1580- }
1581- showSnackbar(
1582- String .format(
1583- context.resources.getString(R .string.deleted_conversation),
1584- conversation.displayName
1585- )
1571+ when (workInfo?.state) {
1572+ WorkInfo .State .SUCCEEDED -> {
1573+ currentUser.id?.let { userId ->
1574+ ShortcutManagerHelper .disableConversationShortcut(
1575+ context,
1576+ conversation.token,
1577+ userId,
1578+ context.resources.getString(R .string.nc_shortcut_conversation_deleted)
15861579 )
15871580 }
1581+ conversation.token?.let { conversationsListViewModel.clearConversationPendingRemoval(it) }
1582+ // the worker only deletes the room on the server, so without this the entry
1583+ // comes back as soon as it stops being hidden
1584+ fetchRooms()
1585+ showSnackbar(
1586+ String .format(
1587+ context.resources.getString(R .string.deleted_conversation),
1588+ conversation.displayName
1589+ )
1590+ )
1591+ }
15881592
1589- WorkInfo .State .FAILED -> {
1590- logger.e(TAG , " DeleteConversationWorker failed for token ${conversation.token} " )
1591- showSnackbar(context.resources.getString(R .string.nc_common_error_sorry))
1592- }
1593+ WorkInfo .State .FAILED -> {
1594+ logger.e(TAG , " DeleteConversationWorker failed for token ${conversation.token} " )
1595+ conversation.token?.let { conversationsListViewModel.clearConversationPendingRemoval(it) }
1596+ showSnackbar(context.resources.getString(R .string.nc_common_error_sorry))
1597+ }
15931598
1594- else -> {
1595- }
1599+ WorkInfo .State .CANCELLED -> {
1600+ // nothing was deleted, so the entry must not stay hidden
1601+ conversation.token?.let { conversationsListViewModel.clearConversationPendingRemoval(it) }
1602+ }
1603+
1604+ else -> {
15961605 }
15971606 }
15981607 }
0 commit comments