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
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>()
/**
* Used by DataStoreHelper to fully reload library when switching accounts
*/
val reloadLibraryEvent = Event<Boolean>()
/**

View file

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

View file

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