From c7ecd90817daa65a058f456205121842f1b2b328 Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Tue, 28 Apr 2020 15:08:37 +0300 Subject: [PATCH 1/4] Add the per-folder local message cleanup Signed-off-by: Vasyl Gello --- .../managefolders/FolderSettingsFragment.kt | 63 ++++++++++++++++++- .../managefolders/FolderSettingsViewModel.kt | 36 +++++++++-- .../fsck/k9/ui/managefolders/KoinModule.kt | 2 +- .../main/res/menu/folder_settings_option.xml | 10 +++ app/ui/src/main/res/values/strings.xml | 4 ++ 5 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 app/ui/src/main/res/menu/folder_settings_option.xml diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt index 5a2442ff7..0fd9cac7b 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt @@ -1,9 +1,14 @@ package com.fsck.k9.ui.managefolders import android.os.Bundle +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem import android.view.View import androidx.navigation.fragment.findNavController import androidx.preference.Preference +import com.fsck.k9.fragment.ConfirmationDialogFragment +import com.fsck.k9.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmentListener import com.fsck.k9.ui.R import com.fsck.k9.ui.folders.FolderNameFormatter import com.fsck.k9.ui.observeNotNull @@ -12,7 +17,7 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -class FolderSettingsFragment : PreferenceFragmentCompat() { +class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFragmentListener { private val viewModel: FolderSettingsViewModel by viewModel() private val folderNameFormatter: FolderNameFormatter by inject { parametersOf(requireActivity()) } @@ -21,6 +26,26 @@ class FolderSettingsFragment : PreferenceFragmentCompat() { setPreferencesFromResource(R.xml.empty_preferences, null) } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.folder_settings_option, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + R.id.clear_local_folder -> { + viewModel.showClearFolderConfirmationDialog() + true + } + else -> super.onOptionsItemSelected(item) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setHasOptionsMenu(true) + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -35,6 +60,8 @@ class FolderSettingsFragment : PreferenceFragmentCompat() { is FolderSettingsData -> initPreferences(folderSettingsResult) } } + + viewModel.getActionEvents().observeNotNull(this) { handleActionEvents(it) } } private fun navigateBack() { @@ -53,10 +80,44 @@ class FolderSettingsFragment : PreferenceFragmentCompat() { findPreference(PREFERENCE_TOP_CATEGORY)!!.title = folderDisplayName } + private fun handleActionEvents(action: Action) { + when (action) { + is Action.ShowClearFolderConfirmationDialog -> showClearFolderConfirmationDialog() + } + } + + private fun showClearFolderConfirmationDialog() { + val dialogFragment = ConfirmationDialogFragment.newInstance( + DIALOG_CLEAR_FOLDER, + getString(R.string.dialog_confirm_clear_local_folder_title), + getString(R.string.dialog_confirm_clear_local_folder_message), + getString(R.string.okay_action), + getString(R.string.cancel_action) + ) + dialogFragment.setTargetFragment(this, REQUEST_CLEAR_FOLDER) + dialogFragment.show(requireFragmentManager(), TAG_CLEAR_FOLDER_CONFIRMATION) + } + + override fun doPositiveClick(dialogId: Int) { + when (dialogId) { + DIALOG_CLEAR_FOLDER -> { + viewModel.onClearFolderConfirmation() + } + } + } + + override fun doNegativeClick(dialogId: Int) = Unit + + override fun dialogCancelled(dialogId: Int) = Unit + companion object { const val EXTRA_ACCOUNT = "account" const val EXTRA_FOLDER_ID = "folderId" + private const val DIALOG_CLEAR_FOLDER = 1 + private const val REQUEST_CLEAR_FOLDER = 1 + private const val TAG_CLEAR_FOLDER_CONFIRMATION = "clear_folder_confirmation" + private const val PREFERENCE_TOP_CATEGORY = "folder_settings" } } diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt index 0beea3a03..74151fa1a 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt @@ -7,6 +7,8 @@ import androidx.lifecycle.viewModelScope import com.fsck.k9.Account import com.fsck.k9.Preferences import com.fsck.k9.activity.FolderInfoHolder +import com.fsck.k9.controller.MessagingController +import com.fsck.k9.helper.SingleLiveEvent import com.fsck.k9.mailstore.Folder import com.fsck.k9.mailstore.FolderDetails import com.fsck.k9.mailstore.FolderRepository @@ -17,10 +19,15 @@ import timber.log.Timber class FolderSettingsViewModel( private val preferences: Preferences, - private val folderRepositoryManager: FolderRepositoryManager + private val folderRepositoryManager: FolderRepositoryManager, + private val messagingController: MessagingController ) : ViewModel() { + private val actionLiveData = SingleLiveEvent() private var folderSettingsLiveData: LiveData? = null + private lateinit var folderAccount: Account + private lateinit var folderServerId: String + fun getFolderSettingsLiveData(accountUuid: String, folderId: Long): LiveData { return folderSettingsLiveData ?: createFolderSettingsLiveData(accountUuid, folderId).also { folderSettingsLiveData = it @@ -32,8 +39,9 @@ class FolderSettingsViewModel( folderId: Long ): LiveData { return liveData(context = viewModelScope.coroutineContext) { - val account = loadAccount(accountUuid) - val folderRepository = folderRepositoryManager.getFolderRepository(account) + folderAccount = loadAccount(accountUuid) + + val folderRepository = folderRepositoryManager.getFolderRepository(folderAccount) val folderDetails = folderRepository.loadFolderDetails(folderId) if (folderDetails == null) { Timber.w("Folder with ID $folderId not found") @@ -41,8 +49,10 @@ class FolderSettingsViewModel( return@liveData } + folderServerId = folderDetails.folder.serverId + val folderSettingsData = FolderSettingsData( - folder = createFolderObject(account, folderDetails.folder), + folder = createFolderObject(folderAccount, folderDetails.folder), dataStore = FolderSettingsDataStore(folderRepository, folderDetails) ) emit(folderSettingsData) @@ -70,8 +80,26 @@ class FolderSettingsViewModel( type = folderType ) } + + fun showClearFolderConfirmationDialog() { + sendActionEvent(Action.ShowClearFolderConfirmationDialog) + } + + fun onClearFolderConfirmation() { + messagingController.clearFolder(folderAccount, folderServerId, null) + } + + fun getActionEvents(): LiveData = actionLiveData + + private fun sendActionEvent(action: Action) { + actionLiveData.value = action + } } sealed class FolderSettingsResult object FolderNotFound : FolderSettingsResult() data class FolderSettingsData(val folder: Folder, val dataStore: FolderSettingsDataStore) : FolderSettingsResult() + +sealed class Action { + object ShowClearFolderConfirmationDialog : Action() +} diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/KoinModule.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/KoinModule.kt index ca3cc67df..7f9b1ca63 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/KoinModule.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/KoinModule.kt @@ -5,5 +5,5 @@ import org.koin.dsl.module val manageFoldersUiModule = module { viewModel { ManageFoldersViewModel(foldersLiveDataFactory = get()) } - viewModel { FolderSettingsViewModel(preferences = get(), folderRepositoryManager = get()) } + viewModel { FolderSettingsViewModel(preferences = get(), folderRepositoryManager = get(), messagingController = get()) } } diff --git a/app/ui/src/main/res/menu/folder_settings_option.xml b/app/ui/src/main/res/menu/folder_settings_option.xml new file mode 100644 index 000000000..23f635a00 --- /dev/null +++ b/app/ui/src/main/res/menu/folder_settings_option.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/app/ui/src/main/res/values/strings.xml b/app/ui/src/main/res/values/strings.xml index f29c838cb..a97bb9157 100644 --- a/app/ui/src/main/res/values/strings.xml +++ b/app/ui/src/main/res/values/strings.xml @@ -662,6 +662,7 @@ Please submit bug reports, contribute new features and ask questions at 1st Class 2nd Class Same as push class + Clear local messages Incoming server Configure the incoming mail server @@ -893,6 +894,9 @@ Please submit bug reports, contribute new features and ask questions at Select text to copy. + Confirm local folder clear + Do you really want to delete all local messages from this folder? + Confirm deletion Do you want to delete this message? From 3bdda4eac1def0254a34adf8fcef5c386918b067 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 4 May 2020 11:01:19 +0200 Subject: [PATCH 2/4] Cleanup --- .../managefolders/FolderSettingsFragment.kt | 42 +++++++++---------- .../managefolders/FolderSettingsViewModel.kt | 8 ++-- app/ui/src/main/res/values/strings.xml | 5 ++- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt index 0fd9cac7b..5dac0963a 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt @@ -21,31 +21,16 @@ class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFra private val viewModel: FolderSettingsViewModel by viewModel() private val folderNameFormatter: FolderNameFormatter by inject { parametersOf(requireActivity()) } - override fun onCreatePreferencesFix(savedInstanceState: Bundle?, rootKey: String?) { - // Set empty preferences resource while data is being loaded - setPreferencesFromResource(R.xml.empty_preferences, null) - } - - override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - super.onCreateOptionsMenu(menu, inflater) - inflater.inflate(R.menu.folder_settings_option, menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.clear_local_folder -> { - viewModel.showClearFolderConfirmationDialog() - true - } - else -> super.onOptionsItemSelected(item) - } - } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) } + override fun onCreatePreferencesFix(savedInstanceState: Bundle?, rootKey: String?) { + // Set empty preferences resource while data is being loaded + setPreferencesFromResource(R.xml.empty_preferences, null) + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -64,6 +49,21 @@ class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFra viewModel.getActionEvents().observeNotNull(this) { handleActionEvents(it) } } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.folder_settings_option, menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + return when (item.itemId) { + R.id.clear_local_folder -> { + viewModel.showClearFolderConfirmationDialog() + true + } + else -> super.onOptionsItemSelected(item) + } + } + private fun navigateBack() { findNavController().popBackStack() } @@ -91,7 +91,7 @@ class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFra DIALOG_CLEAR_FOLDER, getString(R.string.dialog_confirm_clear_local_folder_title), getString(R.string.dialog_confirm_clear_local_folder_message), - getString(R.string.okay_action), + getString(R.string.dialog_confirm_clear_local_folder_action), getString(R.string.cancel_action) ) dialogFragment.setTargetFragment(this, REQUEST_CLEAR_FOLDER) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt index 74151fa1a..303c45cb5 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt @@ -39,9 +39,8 @@ class FolderSettingsViewModel( folderId: Long ): LiveData { return liveData(context = viewModelScope.coroutineContext) { - folderAccount = loadAccount(accountUuid) - - val folderRepository = folderRepositoryManager.getFolderRepository(folderAccount) + val account = loadAccount(accountUuid) + val folderRepository = folderRepositoryManager.getFolderRepository(account) val folderDetails = folderRepository.loadFolderDetails(folderId) if (folderDetails == null) { Timber.w("Folder with ID $folderId not found") @@ -49,10 +48,11 @@ class FolderSettingsViewModel( return@liveData } + folderAccount = account folderServerId = folderDetails.folder.serverId val folderSettingsData = FolderSettingsData( - folder = createFolderObject(folderAccount, folderDetails.folder), + folder = createFolderObject(account, folderDetails.folder), dataStore = FolderSettingsDataStore(folderRepository, folderDetails) ) emit(folderSettingsData) diff --git a/app/ui/src/main/res/values/strings.xml b/app/ui/src/main/res/values/strings.xml index a97bb9157..7405dfc3b 100644 --- a/app/ui/src/main/res/values/strings.xml +++ b/app/ui/src/main/res/values/strings.xml @@ -894,8 +894,9 @@ Please submit bug reports, contribute new features and ask questions at Select text to copy. - Confirm local folder clear - Do you really want to delete all local messages from this folder? + Clear local messages? + This will remove all local messages from the folder. No messages will be deleted from the server. + Clear messages Confirm deletion Do you want to delete this message? From 33d7b31ff97e022b1036712f1d22065fb69a6b6a Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 4 May 2020 11:19:43 +0200 Subject: [PATCH 3/4] Only show "clear local messages" in menu after data has been loaded --- .../fsck/k9/ui/managefolders/FolderSettingsFragment.kt | 8 ++++++++ .../fsck/k9/ui/managefolders/FolderSettingsViewModel.kt | 3 +++ 2 files changed, 11 insertions(+) diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt index 5dac0963a..b8cd6a771 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsFragment.kt @@ -52,6 +52,9 @@ class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFra override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { super.onCreateOptionsMenu(menu, inflater) inflater.inflate(R.menu.folder_settings_option, menu) + + val clearFolderItem = menu.findItem(R.id.clear_local_folder) + clearFolderItem.isVisible = viewModel.showClearFolderInMenu } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -73,6 +76,11 @@ class FolderSettingsFragment : PreferenceFragmentCompat(), ConfirmationDialogFra setPreferencesFromResource(R.xml.folder_settings_preferences, null) setCategoryTitle(folderSettings) + updateMenu() + } + + private fun updateMenu() { + requireActivity().invalidateOptionsMenu() } private fun setCategoryTitle(folderSettings: FolderSettingsData) { diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt index 303c45cb5..25ac744af 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt @@ -28,6 +28,9 @@ class FolderSettingsViewModel( private lateinit var folderAccount: Account private lateinit var folderServerId: String + val showClearFolderInMenu: Boolean + get() = this::folderAccount.isInitialized && this::folderServerId.isInitialized + fun getFolderSettingsLiveData(accountUuid: String, folderId: Long): LiveData { return folderSettingsLiveData ?: createFolderSettingsLiveData(accountUuid, folderId).also { folderSettingsLiveData = it From 17bda4029c1b34c83e9dfc536d007cf52148ae12 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 4 May 2020 11:28:06 +0200 Subject: [PATCH 4/4] Change MessagingController.clearFolder() to use the folderId --- .../fsck/k9/controller/MessagingController.java | 15 ++++++--------- .../k9/controller/MessagingControllerTest.java | 13 ++++++++----- .../ui/managefolders/FolderSettingsViewModel.kt | 14 ++++++++------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java index 9907bae77..14002ab21 100644 --- a/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/app/core/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -2235,20 +2235,17 @@ public class MessagingController { }); } - public void clearFolder(final Account account, final String folderServerId, final MessagingListener listener) { - putBackground("clearFolder", listener, new Runnable() { - @Override - public void run() { - clearFolderSynchronous(account, folderServerId, listener); - } - }); + public void clearFolder(Account account, long folderId) { + putBackground("clearFolder", null, () -> + clearFolderSynchronous(account, folderId) + ); } @VisibleForTesting - protected void clearFolderSynchronous(Account account, String folderServerId, MessagingListener listener) { + protected void clearFolderSynchronous(Account account, long folderId) { LocalFolder localFolder = null; try { - localFolder = localStoreProvider.getInstance(account).getFolder(folderServerId); + localFolder = localStoreProvider.getInstance(account).getFolder(folderId); localFolder.open(); localFolder.clearAllMessages(); } catch (UnavailableStorageException e) { diff --git a/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java b/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java index d4c19f346..923aae733 100644 --- a/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java +++ b/app/core/src/test/java/com/fsck/k9/controller/MessagingControllerTest.java @@ -73,6 +73,7 @@ import static org.mockito.Mockito.when; @SuppressWarnings("unchecked") public class MessagingControllerTest extends K9RobolectricTest { + private static final long FOLDER_ID = 23; private static final String FOLDER_NAME = "Folder"; private static final String SENT_FOLDER_NAME = "Sent"; private static final int MAXIMUM_SMALL_MESSAGE_SIZE = 1000; @@ -158,21 +159,21 @@ public class MessagingControllerTest extends K9RobolectricTest { @Test public void clearFolderSynchronous_shouldOpenFolderForWriting() throws MessagingException { - controller.clearFolderSynchronous(account, FOLDER_NAME, listener); + controller.clearFolderSynchronous(account, FOLDER_ID); verify(localFolder).open(); } @Test public void clearFolderSynchronous_shouldClearAllMessagesInTheFolder() throws MessagingException { - controller.clearFolderSynchronous(account, FOLDER_NAME, listener); + controller.clearFolderSynchronous(account, FOLDER_ID); verify(localFolder).clearAllMessages(); } @Test public void clearFolderSynchronous_shouldCloseTheFolder() throws MessagingException { - controller.clearFolderSynchronous(account, FOLDER_NAME, listener); + controller.clearFolderSynchronous(account, FOLDER_ID); verify(localFolder, atLeastOnce()).close(); } @@ -181,7 +182,7 @@ public class MessagingControllerTest extends K9RobolectricTest { public void clearFolderSynchronous_whenStorageUnavailable_shouldThrowUnavailableAccountException() throws MessagingException { doThrow(new UnavailableStorageException("Test")).when(localFolder).open(); - controller.clearFolderSynchronous(account, FOLDER_NAME, listener); + controller.clearFolderSynchronous(account, FOLDER_ID); } @Test() @@ -189,7 +190,7 @@ public class MessagingControllerTest extends K9RobolectricTest { doThrow(new RuntimeException("Test")).when(localFolder).open(); try { - controller.clearFolderSynchronous(account, FOLDER_NAME, listener); + controller.clearFolderSynchronous(account, FOLDER_ID); } catch (Exception ignored){ } @@ -486,6 +487,8 @@ public class MessagingControllerTest extends K9RobolectricTest { private void configureLocalStore() throws MessagingException { when(localStore.getFolder(FOLDER_NAME)).thenReturn(localFolder); + when(localStore.getFolder(FOLDER_ID)).thenReturn(localFolder); + when(localFolder.getDatabaseId()).thenReturn(FOLDER_ID); when(localFolder.getServerId()).thenReturn(FOLDER_NAME); when(localStore.getPersonalNamespaces(false)).thenReturn(Collections.singletonList(localFolder)); when(localStoreProvider.getInstance(account)).thenReturn(localStore); diff --git a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt index 25ac744af..48ab55cc5 100644 --- a/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt +++ b/app/ui/src/main/java/com/fsck/k9/ui/managefolders/FolderSettingsViewModel.kt @@ -17,6 +17,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import timber.log.Timber +private const val NO_FOLDER_ID = 0L + class FolderSettingsViewModel( private val preferences: Preferences, private val folderRepositoryManager: FolderRepositoryManager, @@ -25,11 +27,11 @@ class FolderSettingsViewModel( private val actionLiveData = SingleLiveEvent() private var folderSettingsLiveData: LiveData? = null - private lateinit var folderAccount: Account - private lateinit var folderServerId: String + private lateinit var account: Account + private var folderId: Long = NO_FOLDER_ID val showClearFolderInMenu: Boolean - get() = this::folderAccount.isInitialized && this::folderServerId.isInitialized + get() = this::account.isInitialized && folderId != NO_FOLDER_ID fun getFolderSettingsLiveData(accountUuid: String, folderId: Long): LiveData { return folderSettingsLiveData ?: createFolderSettingsLiveData(accountUuid, folderId).also { @@ -51,8 +53,8 @@ class FolderSettingsViewModel( return@liveData } - folderAccount = account - folderServerId = folderDetails.folder.serverId + this@FolderSettingsViewModel.account = account + this@FolderSettingsViewModel.folderId = folderId val folderSettingsData = FolderSettingsData( folder = createFolderObject(account, folderDetails.folder), @@ -89,7 +91,7 @@ class FolderSettingsViewModel( } fun onClearFolderConfirmation() { - messagingController.clearFolder(folderAccount, folderServerId, null) + messagingController.clearFolder(account, folderId) } fun getActionEvents(): LiveData = actionLiveData