mirror of
https://github.com/yattee/yattee.git
synced 2026-10-29 16:07:20 +00:00
Lay groundwork for the player panels redesign
Phase 0 of the panels redesign, extraction only, no behavior changes: - Unify comments loading on PlayerState: loadComments/loadMoreComments become the single loader, used by both the player sheet preload and the comments overlay (which previously had its own duplicate copy). - Extract PanelResizeGrabber from FloatingDetailsPanel into the new Views/Player/Panels/ directory. - Extract the shared queue list from QueueManagementSheet into QueueListView plus QueuePlaybackActions, reused by the tvOS panel. - Remove the no-op wideLayoutPanelAlignment accessor from the settings view model; the player reads the panel side from SettingsManager, so the preset field was dead. The Codable field stays so old presets decode.
This commit is contained in:
@@ -329,73 +329,12 @@ struct ExpandedCommentsView: View {
|
||||
|
||||
private func loadComments() async {
|
||||
guard let playerState, let contentService, let instancesManager else { return }
|
||||
|
||||
// Don't load comments for non-YouTube videos
|
||||
guard let video = playerState.currentVideo, video.supportsComments else {
|
||||
playerState.commentsState = .disabled
|
||||
return
|
||||
}
|
||||
|
||||
// Capture the video ID we're loading comments for
|
||||
let requestedVideoID = videoID
|
||||
|
||||
guard let instance = instancesManager.instance(for: video) else { return }
|
||||
|
||||
playerState.commentsState = .loading
|
||||
|
||||
do {
|
||||
let page = try await contentService.comments(videoID: videoID, instance: instance, continuation: nil)
|
||||
|
||||
// Validate player is still on the same video
|
||||
guard !Task.isCancelled,
|
||||
playerState.currentVideo?.id.videoID == requestedVideoID else { return }
|
||||
|
||||
playerState.comments = page.comments
|
||||
playerState.commentsContinuation = page.continuation
|
||||
playerState.commentsState = .loaded
|
||||
} catch let error as APIError where error == .commentsDisabled {
|
||||
guard !Task.isCancelled,
|
||||
playerState.currentVideo?.id.videoID == requestedVideoID else { return }
|
||||
playerState.commentsState = .disabled
|
||||
} catch {
|
||||
guard !Task.isCancelled,
|
||||
playerState.currentVideo?.id.videoID == requestedVideoID else { return }
|
||||
playerState.commentsState = .error
|
||||
}
|
||||
await playerState.loadComments(contentService: contentService, instancesManager: instancesManager)
|
||||
}
|
||||
|
||||
private func loadMoreComments() async {
|
||||
guard let playerState, let contentService, let instancesManager else { return }
|
||||
guard let continuation = playerState.commentsContinuation else { return }
|
||||
|
||||
// Don't load more comments for non-YouTube videos
|
||||
guard let video = playerState.currentVideo, video.supportsComments else {
|
||||
return
|
||||
}
|
||||
|
||||
// Capture the video ID we're loading comments for
|
||||
let requestedVideoID = videoID
|
||||
|
||||
guard let instance = instancesManager.instance(for: video) else { return }
|
||||
|
||||
playerState.commentsState = .loadingMore
|
||||
|
||||
do {
|
||||
let page = try await contentService.comments(videoID: videoID, instance: instance, continuation: continuation)
|
||||
|
||||
// Validate player is still on the same video
|
||||
guard !Task.isCancelled,
|
||||
playerState.currentVideo?.id.videoID == requestedVideoID else { return }
|
||||
|
||||
playerState.comments.append(contentsOf: page.comments)
|
||||
playerState.commentsContinuation = page.continuation
|
||||
playerState.commentsState = .loaded
|
||||
} catch {
|
||||
guard !Task.isCancelled,
|
||||
playerState.currentVideo?.id.videoID == requestedVideoID else { return }
|
||||
// Don't change state to error on load more failure
|
||||
playerState.commentsState = .loaded
|
||||
}
|
||||
await playerState.loadMoreComments(contentService: contentService, instancesManager: instancesManager)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user