From a95ba411962b6dae0a560d86b10ab0e3230d964a Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 17 Apr 2024 16:33:10 -0300 Subject: [PATCH] Reset WebDAV config state when the UI is left --- .../stevesoltys/seedvault/plugins/webdav/WebDavHandler.kt | 4 ++++ .../com/stevesoltys/seedvault/ui/storage/StorageViewModel.kt | 2 ++ .../stevesoltys/seedvault/ui/storage/WebDavConfigFragment.kt | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavHandler.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavHandler.kt index d471901a..371cf70b 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavHandler.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/webdav/WebDavHandler.kt @@ -65,6 +65,10 @@ internal class WebDavHandler( } } + fun resetConfigState() { + _configState.value = WebDavConfigState.Empty + } + /** * Searches if there's really an app backup available in the given storage location. * Returns true if at least one was found and false otherwise. diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageViewModel.kt index fe5b7a8a..ea3cc3ac 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageViewModel.kt @@ -99,6 +99,8 @@ internal abstract class StorageViewModel( } } + fun resetWebDavConfig() = webdavHandler.resetConfigState() + @UiThread fun onWebDavConfigSuccess(properties: WebDavProperties, plugin: WebDavStoragePlugin) { mLocationSet.setEvent(true) diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/WebDavConfigFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/WebDavConfigFragment.kt index 90f502df..a302a8d5 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/WebDavConfigFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/WebDavConfigFragment.kt @@ -93,6 +93,11 @@ class WebDavConfigFragment : Fragment(), View.OnClickListener { } } + override fun onDestroy() { + viewModel.resetWebDavConfig() + super.onDestroy() + } + private fun onConfigStateChanged(state: WebDavConfigState) { when (state) { WebDavConfigState.Empty -> {