mirror of
https://github.com/yattee/yattee.git
synced 2026-08-06 07:11:28 +00:00
Fix #960: scope subscription counts, import/export to active account
When an Invidious/Piped account is active, several views read the local SwiftData subscription store instead of the account, so counts contradicted each other (Home tile said 10 while the Channels list showed the server's 2): - Home Channels tile now uses the provider's count via new SubscriptionService.cachedSubscriptionCount (fetched once in the background when the server cache isn't populated yet) - Export footer and export content use the active account's list; export runs async with a spinner and surfaces fetch errors as a toast - CSV/OPML import routes through SubscriptionService.importSubscriptions, subscribing on the server for server accounts instead of silently writing to the invisible local store - ChannelView subscribe-state is corrected via the provider after the optimistic local-store read; unused *Sync write helpers removed - Server-account subscribe/unsubscribe/import now post subscriptionsDidChange so other views refresh - New "Delete Local Subscription Data" section in Subscriptions settings (visible with a server account) clears the local store and queues CloudKit deletions so iCloud doesn't restore it
This commit is contained in:
@@ -2097,9 +2097,13 @@ struct ChannelView: View {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
|
||||
// Load subscription state
|
||||
// Load subscription state: optimistic from the local store, then
|
||||
// corrected by the active provider (server accounts differ from local)
|
||||
subscription = appEnvironment.dataManager.subscription(for: channelID)
|
||||
isSubscribed = subscription != nil
|
||||
Task {
|
||||
isSubscribed = await appEnvironment.subscriptionService.isSubscribed(to: channelID)
|
||||
}
|
||||
|
||||
// Load cached header data for immediate display
|
||||
cachedHeader = CachedChannelData.load(for: channelID, using: appEnvironment.dataManager)
|
||||
@@ -2212,6 +2216,9 @@ struct ChannelView: View {
|
||||
// Check subscription status using extracted channel ID
|
||||
subscription = appEnvironment.dataManager.subscription(for: fetchedChannel.id.channelID)
|
||||
isSubscribed = subscription != nil
|
||||
Task {
|
||||
isSubscribed = await appEnvironment.subscriptionService.isSubscribed(to: fetchedChannel.id.channelID)
|
||||
}
|
||||
}
|
||||
} catch let error as APIError {
|
||||
await MainActor.run {
|
||||
@@ -2247,6 +2254,11 @@ struct ChannelView: View {
|
||||
let effectiveChannelID = channel?.id.channelID ?? channelID
|
||||
subscription = appEnvironment?.dataManager.subscription(for: effectiveChannelID)
|
||||
isSubscribed = subscription != nil
|
||||
Task {
|
||||
if let service = appEnvironment?.subscriptionService {
|
||||
isSubscribed = await service.isSubscribed(to: effectiveChannelID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func loadMoreVideos() async {
|
||||
|
||||
Reference in New Issue
Block a user