diff --git a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt index be7ef9101..746aca559 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/notifications/NotificationsFragment.kt @@ -217,22 +217,14 @@ class NotificationsFragment : } }) - /** - * Collect this flow to notify the adapter that the timestamps of the visible items have - * changed - */ + // update post timestamps val updateTimestampFlow = flow { - while (true) { delay(60000); emit(Unit) } - }.onEach { - layoutManager.findFirstVisibleItemPosition().let { first -> - first == RecyclerView.NO_POSITION && return@let - val count = layoutManager.findLastVisibleItemPosition() - first - adapter.notifyItemRangeChanged( - first, - count, - listOf(StatusBaseViewHolder.Key.KEY_CREATED) - ) + while (true) { + delay(60000) + emit(Unit) } + }.onEach { + adapter.notifyItemRangeChanged(0, adapter.itemCount, listOf(StatusBaseViewHolder.Key.KEY_CREATED)) } viewLifecycleOwner.lifecycleScope.launch { @@ -366,20 +358,14 @@ class NotificationsFragment : } // Update status display from statusDisplayOptions. If the new options request - // relative time display collect the flow to periodically re-bind the UI. + // relative time display collect the flow to periodically update the timestamp in the list gui elements. launch { viewModel.statusDisplayOptions .collectLatest { + // NOTE this this also triggered (emitted?) on resume. + adapter.statusDisplayOptions = it - layoutManager.findFirstVisibleItemPosition().let { first -> - first == RecyclerView.NO_POSITION && return@let - val count = layoutManager.findLastVisibleItemPosition() - first - adapter.notifyItemRangeChanged( - first, - count, - null - ) - } + adapter.notifyItemRangeChanged(0, adapter.itemCount, null) if (!it.useAbsoluteTime) { updateTimestampFlow.collect()