mirror of
https://github.com/yattee/yattee.git
synced 2026-02-19 09:19:46 +00:00
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:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user