Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: Log the trigger for a refresh/reload #466

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class CachedTimelineRepository @Inject constructor(

/** Remove all statuses and invalidate the pager, for the active account */
suspend fun clearAndReload() = externalScope.launch {
Timber.d("clearAndReload()")
timelineDao.removeAll(activeAccount!!.id)
factory?.invalidate()
}.join()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,15 @@ class TimelineFragment :
return when (menuItem.itemId) {
R.id.action_refresh -> {
if (isSwipeToRefreshEnabled) {
Timber.d("Reload because user chose refresh menu item")
refreshContent()
true
} else {
false
}
}
R.id.action_load_newest -> {
Timber.d("Reload because user choose load newest menu item")
viewModel.accept(InfallibleUiAction.LoadNewest)
refreshContent()
true
Expand Down Expand Up @@ -556,6 +558,7 @@ class TimelineFragment :

/** Refresh the displayed content, as if the user had swiped on the SwipeRefreshLayout */
override fun refreshContent() {
Timber.d("Reloading via refreshContent")
binding.swipeRefreshLayout.isRefreshing = true
onRefresh()
}
Expand All @@ -565,6 +568,7 @@ class TimelineFragment :
* handled displaying the animated spinner.
*/
override fun onRefresh() {
Timber.d("Reloading via onRefresh")
binding.statusView.hide()
snackbar?.dismiss()
adapter.refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ abstract class TimelineViewModel(
activeAccount.lastVisibleHomeTimelineStatusId = null
accountManager.saveAccount(activeAccount)
}
Timber.d("Reload because InfallibleUiAction.LoadNewest")
reloadFromNewest()
}
}
Expand Down Expand Up @@ -523,6 +524,7 @@ abstract class TimelineViewModel(
.filter { filterContextMatchesKind(timelineKind, listOf(it.filterKind)) }
.map {
getFilters()
Timber.d("Reload because FilterChangedEvent")
reloadKeepingReadingPosition()
}
.onStart { getFilters() }
Expand Down Expand Up @@ -552,6 +554,7 @@ abstract class TimelineViewModel(
val oldRemoveReplies = filterRemoveReplies
filterRemoveReplies = timelineKind is TimelineKind.Home && !filter
if (oldRemoveReplies != filterRemoveReplies) {
Timber.d("Reload because TAB_FILTER_HOME_REPLIES changed")
reloadKeepingReadingPosition()
}
}
Expand All @@ -560,6 +563,7 @@ abstract class TimelineViewModel(
val oldRemoveReblogs = filterRemoveReblogs
filterRemoveReblogs = timelineKind is TimelineKind.Home && !filter
if (oldRemoveReblogs != filterRemoveReblogs) {
Timber.d("Reload because TAB_FILTER_HOME_BOOSTS changed")
reloadKeepingReadingPosition()
}
}
Expand All @@ -568,6 +572,7 @@ abstract class TimelineViewModel(
val oldRemoveSelfReblogs = filterRemoveSelfReblogs
filterRemoveSelfReblogs = timelineKind is TimelineKind.Home && !filter
if (oldRemoveSelfReblogs != filterRemoveSelfReblogs) {
Timber.d("Reload because TAB_SHOW_SOME_SELF_BOOSTS changed")
reloadKeepingReadingPosition()
}
}
Expand All @@ -580,7 +585,10 @@ abstract class TimelineViewModel(
is ReblogEvent -> handleReblogEvent(event)
is BookmarkEvent -> handleBookmarkEvent(event)
is PinEvent -> handlePinEvent(event)
is MuteConversationEvent -> reloadKeepingReadingPosition()
is MuteConversationEvent -> {
Timber.d("Reload because MuteConversationEvent")
reloadKeepingReadingPosition()
}
is UnfollowEvent -> {
if (timelineKind is TimelineKind.Home) {
val id = event.accountId
Expand Down
Loading