mirror of
https://github.com/yattee/yattee.git
synced 2026-10-30 16:37:17 +00:00
Let the sidebar's channels and playlists follow the data context
This commit is contained in:
@@ -139,6 +139,10 @@ final class InvidiousSubscriptionProvider: SubscriptionProvider {
|
||||
cachePopulated ? cachedChannels.count : nil
|
||||
}
|
||||
|
||||
var cachedSubscriptions: [Channel]? {
|
||||
cachePopulated ? cachedChannels : nil
|
||||
}
|
||||
|
||||
// MARK: - Private Helpers
|
||||
|
||||
/// Gets the authenticated Invidious instance and session ID from account settings.
|
||||
|
||||
@@ -26,7 +26,12 @@ final class LocalSubscriptionProvider: SubscriptionProvider {
|
||||
// MARK: - SubscriptionProvider
|
||||
|
||||
func fetchSubscriptions() async throws -> [Channel] {
|
||||
// Convert Subscription models to Channel models
|
||||
subscriptionChannels()
|
||||
}
|
||||
|
||||
/// Converts Subscription models to Channel models, synchronously — the
|
||||
/// store is local, so there is nothing to await.
|
||||
private func subscriptionChannels() -> [Channel] {
|
||||
dataManager.subscriptions().map { subscription in
|
||||
Channel(
|
||||
id: ChannelID(source: subscription.contentSource, channelID: subscription.channelID),
|
||||
@@ -67,4 +72,9 @@ final class LocalSubscriptionProvider: SubscriptionProvider {
|
||||
var cachedSubscriptionCount: Int? {
|
||||
dataManager.subscriptionCount
|
||||
}
|
||||
|
||||
var cachedSubscriptions: [Channel]? {
|
||||
// Local data needs no cache warm-up — the store is always readable.
|
||||
subscriptionChannels()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,10 @@ final class PipedSubscriptionProvider: SubscriptionProvider {
|
||||
cachePopulated ? cachedChannels.count : nil
|
||||
}
|
||||
|
||||
var cachedSubscriptions: [Channel]? {
|
||||
cachePopulated ? cachedChannels : nil
|
||||
}
|
||||
|
||||
// MARK: - Private Helpers
|
||||
|
||||
/// Gets the authenticated Piped instance and auth token from account settings.
|
||||
|
||||
@@ -40,6 +40,10 @@ protocol SubscriptionProvider: Sendable {
|
||||
/// Returns nil when the provider hasn't populated its cache yet.
|
||||
var cachedSubscriptionCount: Int? { get }
|
||||
|
||||
/// The subscribed channels known without a network fetch.
|
||||
/// Returns nil when the provider hasn't populated its cache yet.
|
||||
var cachedSubscriptions: [Channel]? { get }
|
||||
|
||||
/// Refreshes the local cache of subscriptions from the remote source.
|
||||
/// For local provider, this is a no-op.
|
||||
func refreshCache() async throws
|
||||
|
||||
Reference in New Issue
Block a user