Mark recent changes as read when dismissing snackbar

This commit is contained in:
cketti 2023-01-09 16:29:20 +01:00
parent 2c89a69b17
commit 612f0b9477
2 changed files with 11 additions and 1 deletions

View file

@ -13,7 +13,7 @@ import kotlinx.coroutines.flow.map
@OptIn(ExperimentalCoroutinesApi::class)
class RecentChangesViewModel(
private val generalSettingsManager: GeneralSettingsManager,
changeLogManager: ChangeLogManager
private val changeLogManager: ChangeLogManager
) : ViewModel() {
val shouldShowRecentChangesHint = changeLogManager.changeLogFlow.flatMapLatest { changeLog ->
if (changeLog.isFirstRun && !changeLog.isFirstRunEver) {
@ -28,4 +28,8 @@ class RecentChangesViewModel(
.map { generalSettings -> generalSettings.showRecentChanges }
.distinctUntilChanged()
}
fun onRecentChangesHintDismissed() {
changeLogManager.writeCurrentVersion()
}
}

View file

@ -57,6 +57,7 @@ import com.fsck.k9.ui.folders.FolderNameFormatterFactory
import com.fsck.k9.ui.helper.RelativeDateTimeFormatter
import com.fsck.k9.ui.messagelist.MessageListFragment.MessageListFragmentListener.Companion.MAX_PROGRESS
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.snackbar.BaseTransientBottomBar.BaseCallback
import com.google.android.material.snackbar.Snackbar
import java.util.concurrent.Future
import net.jcip.annotations.GuardedBy
@ -369,6 +370,11 @@ class MessageListFragment :
recentChangesSnackbar = Snackbar
.make(coordinatorLayout, R.string.changelog_snackbar_text, Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.okay_action) { launchRecentChangesActivity() }
.addCallback(object : BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
recentChangesViewModel.onRecentChangesHintDismissed()
}
})
recentChangesViewModel.shouldShowRecentChangesHint
.observe(viewLifecycleOwner, shouldShowRecentChangesHintObserver)