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.
This commit is contained in:
Arkadiusz Fal
2026-02-12 05:17:25 +01:00
parent 24e60916f8
commit d1d7edb5ec

View File

@@ -256,6 +256,8 @@ struct InstanceBrowseView: View {
loadWatchEntries() loadWatchEntries()
} }
.onChange(of: selectedTab) { _, _ in .onChange(of: selectedTab) { _, _ in
isLoading = true
errorMessage = nil
Task { await startContentLoad() } Task { await startContentLoad() }
} }
#if os(iOS) #if os(iOS)
@@ -949,9 +951,11 @@ struct InstanceBrowseView: View {
userPlaylists = playlists userPlaylists = playlists
} }
} catch is CancellationError { } 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 { } 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 { } catch {
errorMessage = error.localizedDescription errorMessage = error.localizedDescription
} }