mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 04:47:48 +01:00
fix: inbox reload when changing type from default and navigating (#406)
This commit is contained in:
parent
d349aa5dbe
commit
f0623ca9a3
@ -3,4 +3,5 @@ package com.github.diegoberaldin.raccoonforlemmy.core.notifications
|
||||
interface ContentResetCoordinator {
|
||||
var resetHome: Boolean
|
||||
var resetExplore: Boolean
|
||||
var resetInbox: Boolean
|
||||
}
|
||||
|
@ -4,4 +4,5 @@ class DefaultContentResetCoordinator : ContentResetCoordinator {
|
||||
|
||||
override var resetHome = false
|
||||
override var resetExplore = false
|
||||
override var resetInbox = false
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ val inboxTabModule = module {
|
||||
coordinator = get(),
|
||||
settingsRepository = get(),
|
||||
notificationCenter = get(),
|
||||
contentResetCoordinator = get(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.github.diegoberaldin.raccoonforlemmy.feature.inbox.main
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.DefaultMviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.MviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.ContentResetCoordinator
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenter
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
@ -22,9 +23,12 @@ class InboxViewModel(
|
||||
private val coordinator: InboxCoordinator,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val notificationCenter: NotificationCenter,
|
||||
private val contentResetCoordinator: ContentResetCoordinator,
|
||||
) : InboxMviModel,
|
||||
MviModel<InboxMviModel.Intent, InboxMviModel.UiState, InboxMviModel.Effect> by mvi {
|
||||
|
||||
private var firstLoad = true
|
||||
|
||||
override fun onStarted() {
|
||||
mvi.onStarted()
|
||||
mvi.scope?.launch {
|
||||
@ -47,10 +51,18 @@ class InboxViewModel(
|
||||
changeUnreadOnly(evt.unreadOnly)
|
||||
}.launchIn(this)
|
||||
|
||||
val settingsUnreadOnly =
|
||||
settingsRepository.currentSettings.value.defaultInboxType.toInboxUnreadOnly()
|
||||
if (uiState.value.unreadOnly != settingsUnreadOnly) {
|
||||
changeUnreadOnly(settingsUnreadOnly)
|
||||
if (contentResetCoordinator.resetInbox) {
|
||||
contentResetCoordinator.resetInbox = false
|
||||
// apply new inbox type
|
||||
firstLoad = true
|
||||
}
|
||||
if (firstLoad) {
|
||||
firstLoad = false
|
||||
val settingsUnreadOnly =
|
||||
settingsRepository.currentSettings.value.defaultInboxType.toInboxUnreadOnly()
|
||||
if (uiState.value.unreadOnly != settingsUnreadOnly) {
|
||||
changeUnreadOnly(settingsUnreadOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -669,6 +669,7 @@ class SettingsViewModel(
|
||||
defaultInboxType = value.toInboxDefaultType(),
|
||||
)
|
||||
saveSettings(settings)
|
||||
contentResetCoordinator.resetInbox = true
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user