From 587817d07a43a1b28b5a1f951dd112f3222d02eb Mon Sep 17 00:00:00 2001 From: "Darryl L. Pierce" Date: Sat, 16 Aug 2025 14:51:36 -0400 Subject: [PATCH] Added persisting the last library path viewed [#140] --- .../org/comixedproject/variant/viewmodel/VariantViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt b/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt index 8e5db88..b6eb5c4 100644 --- a/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt +++ b/shared/src/commonMain/kotlin/org/comixedproject/variant/viewmodel/VariantViewModel.kt @@ -50,6 +50,7 @@ import org.comixedproject.variant.reader.ReaderAPI private const val TAG = "VariantViewModel" private const val ADDRESS_SETTING = "server.address" +private const val LAST_DIRECTORY_SETTING = "server.last-directory" private const val USERNAME_SETTING = "server.username" private const val PASSWORD_SETTING = "server.password" @@ -124,7 +125,7 @@ open class VariantViewModel( private val _browsingState = MutableStateFlow( viewModelScope, BrowsingState( - READER_ROOT, + settings.getString(LAST_DIRECTORY_SETTING, READER_ROOT), "", "", emptyList(), emptyList() ) ) @@ -192,6 +193,8 @@ open class VariantViewModel( } val directory = directoryRepository.findDirectory(path) + Log.debug(TAG, "Saving last visited directory: value=${path}") + settings.putString(LAST_DIRECTORY_SETTING, path) Log.debug(TAG, "Updating browsing state: currentPath=${path}") _browsingState.tryEmit( BrowsingState(