From d1d7edb5ec93392dcdbc061ccb4ca8ac106e0d0e Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 12 Feb 2026 05:17:25 +0100 Subject: [PATCH] Fix Feed tab flashing ContentUnavailableView on initial load When a cancelled load task fell through to `isLoading = false`, it created a 1-frame gap where the empty view rendered before the replacement task set `isLoading` back to `true`. Return early on cancellation so the surviving task controls loading state. --- Yattee/Views/Instances/InstanceBrowseView.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Yattee/Views/Instances/InstanceBrowseView.swift b/Yattee/Views/Instances/InstanceBrowseView.swift index fad8a392..d3ef2697 100644 --- a/Yattee/Views/Instances/InstanceBrowseView.swift +++ b/Yattee/Views/Instances/InstanceBrowseView.swift @@ -256,6 +256,8 @@ struct InstanceBrowseView: View { loadWatchEntries() } .onChange(of: selectedTab) { _, _ in + isLoading = true + errorMessage = nil Task { await startContentLoad() } } #if os(iOS) @@ -949,9 +951,11 @@ struct InstanceBrowseView: View { userPlaylists = playlists } } catch is CancellationError { - // Task was cancelled (e.g., by SwiftUI during pull-to-refresh) — don't show error + // Task was cancelled — another load is taking over, don't touch state + return } catch let error as APIError where error == .cancelled { - // HTTP request was cancelled — don't show error + // HTTP request was cancelled — another load is taking over, don't touch state + return } catch { errorMessage = error.localizedDescription }