Skip to content

fix discover timeline crash#1082

Merged
Tlaster merged 1 commit intomasterfrom
bugfix/discover_timeline_crash
Jul 8, 2025
Merged

fix discover timeline crash#1082
Tlaster merged 1 commit intomasterfrom
bugfix/discover_timeline_crash

Conversation

@Tlaster
Copy link
Copy Markdown
Contributor

@Tlaster Tlaster commented Jul 8, 2025

No description provided.

@Tlaster Tlaster requested a review from Copilot July 8, 2025 03:45
@Tlaster Tlaster enabled auto-merge July 8, 2025 03:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes crashes when a timeline loader is not supported by introducing a NotSupported state and handling it gracefully in the presenter.

  • Introduces a NotSupported case in BaseTimelineLoader and returns an empty PagingData with error states.
  • Updates discoverStatuses() exception message in XQTDataSource to reference XQT.
  • Removes the debug catch { printStackTrace() } and adds upstream error handling in TimelinePresenter.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
TimelinePresenter.kt Wraps loader in a .catch that emits NotSupported, handles it by emitting an empty paging stream, and removes the old debug catch.
XQTDataSource.kt Changes the unsupported operation exception message to "XQT does not support discover statuses".
BaseRemoteMediator.kt Converts BaseTimelineLoader into a sealed interface with a data object NotSupported variant.

)

BaseTimelineLoader.NotSupported ->
flowOf(
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using flowOf(...) produces a finite flow that emits once and then completes. When combined with filterFlow, the overall stream will complete early and stop responding to further filter updates. Consider returning a non-terminating flow (e.g., mapping filterFlow to PagingData.empty(...)) or restructuring so the combined flow continues emitting on filter changes.

Suggested change
flowOf(
filterFlow.map {

Copilot uses AI. Check for mistakes.

internal sealed interface BaseTimelineLoader
internal sealed interface BaseTimelineLoader {
data object NotSupported : BaseTimelineLoader
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data object syntax for NotSupported is experimental in Kotlin 1.9 and requires opt-in to ExperimentalStdlibApi. Please add @OptIn(ExperimentalStdlibApi::class) or replace with a regular object to avoid relying on experimental features.

Suggested change
data object NotSupported : BaseTimelineLoader
object NotSupported : BaseTimelineLoader

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +64
.catch {
emit(BaseTimelineLoader.NotSupported)
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching all exceptions on loader and emitting NotSupported may hide real errors. Consider catching only specific exception types (e.g., UnsupportedOperationException) or at least logging unexpected exceptions to avoid masking other failures.

Suggested change
.catch {
emit(BaseTimelineLoader.NotSupported)
.catch { exception ->
when (exception) {
is UnsupportedOperationException -> emit(BaseTimelineLoader.NotSupported)
else -> {
println("Unexpected error in loader: ${exception.message}")
throw exception
}
}

Copilot uses AI. Check for mistakes.
@Tlaster Tlaster merged commit 6367768 into master Jul 8, 2025
5 checks passed
@Tlaster Tlaster deleted the bugfix/discover_timeline_crash branch July 8, 2025 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants