Use a reloadLibraryEvent so it does not get triggered when we don't need it to

This commit is contained in:
Luna712 2023-11-04 18:50:53 -06:00
parent b167317e11
commit d0cf4c20da
3 changed files with 8 additions and 3 deletions

View file

@ -309,9 +309,13 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
// kinda shitty solution, but cant com main->home otherwise for popups // kinda shitty solution, but cant com main->home otherwise for popups
val bookmarksUpdatedEvent = Event<Boolean>() val bookmarksUpdatedEvent = Event<Boolean>()
/** /**
* Used by data store helper to fully reload home when switching accounts * Used by DataStoreHelper to fully reload home when switching accounts
*/ */
val reloadHomeEvent = Event<Boolean>() val reloadHomeEvent = Event<Boolean>()
/**
* Used by DataStoreHelper to fully reload library when switching accounts
*/
val reloadLibraryEvent = Event<Boolean>()
/** /**

View file

@ -120,11 +120,11 @@ class LibraryViewModel : ViewModel() {
} }
init { init {
MainActivity.bookmarksUpdatedEvent += ::reloadPages MainActivity.reloadLibraryEvent += ::reloadPages
} }
override fun onCleared() { override fun onCleared() {
MainActivity.bookmarksUpdatedEvent -= ::reloadPages MainActivity.reloadLibraryEvent -= ::reloadPages
super.onCleared() super.onCleared()
} }
} }

View file

@ -153,6 +153,7 @@ object DataStoreHelper {
selectedKeyIndex = account.keyIndex selectedKeyIndex = account.keyIndex
showToast(account.name) showToast(account.name)
MainActivity.bookmarksUpdatedEvent(true) MainActivity.bookmarksUpdatedEvent(true)
MainActivity.reloadLibraryEvent(true)
if (refreshHomePage) { if (refreshHomePage) {
MainActivity.reloadHomeEvent(true) MainActivity.reloadHomeEvent(true)
} }