mirror of
https://github.com/yattee/yattee.git
synced 2026-10-31 08:57:17 +00:00
Remove dead code found by Periphery on all platforms
Delete declarations that Periphery reports unused on every platform that compiles them (iOS, macOS, tvOS), including nine views used only by their own previews. Platform-gated code still used on another platform, device- only MPV render paths, migration models, CloudKit record names, App Intents metadata and unused parameters are kept.
This commit is contained in:
@@ -43,61 +43,6 @@ extension DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Subscribes to a channel from an Author.
|
||||
/// - Parameters:
|
||||
/// - author: The author/channel to subscribe to.
|
||||
/// - source: The content source (YouTube or PeerTube).
|
||||
func subscribe(to author: Author, source: ContentSource) {
|
||||
let channelID = author.id
|
||||
let descriptor = FetchDescriptor<Subscription>(
|
||||
predicate: #Predicate { $0.channelID == channelID }
|
||||
)
|
||||
|
||||
do {
|
||||
let existing = try modelContext.fetch(descriptor)
|
||||
guard existing.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
let sourceRaw: String
|
||||
var instanceURL: String?
|
||||
|
||||
switch source {
|
||||
case .global:
|
||||
sourceRaw = "global"
|
||||
case .federated(_, let instance):
|
||||
sourceRaw = "federated"
|
||||
instanceURL = instance.absoluteString
|
||||
case .extracted:
|
||||
// Extracted sources don't support subscriptions
|
||||
return
|
||||
}
|
||||
|
||||
let subscription = Subscription(
|
||||
channelID: channelID,
|
||||
sourceRawValue: sourceRaw,
|
||||
instanceURLString: instanceURL,
|
||||
name: author.name,
|
||||
subscriberCount: author.subscriberCount,
|
||||
avatarURLString: author.thumbnailURL?.absoluteString
|
||||
)
|
||||
modelContext.insert(subscription)
|
||||
save()
|
||||
|
||||
// Queue for CloudKit sync
|
||||
cloudKitSync?.queueSubscriptionSave(subscription)
|
||||
|
||||
let change = SubscriptionChange(addedSubscriptions: [subscription], removedChannelIDs: [])
|
||||
NotificationCenter.default.post(
|
||||
name: .subscriptionsDidChange,
|
||||
object: nil,
|
||||
userInfo: [SubscriptionChange.userInfoKey: change]
|
||||
)
|
||||
} catch {
|
||||
LoggingService.shared.logCloudKitError("Failed to subscribe", error: error)
|
||||
}
|
||||
}
|
||||
|
||||
/// Unsubscribes from a channel.
|
||||
func unsubscribe(from channelID: String) {
|
||||
let descriptor = FetchDescriptor<Subscription>(
|
||||
@@ -137,42 +82,6 @@ extension DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Bulk adds subscriptions from channel data (for testing).
|
||||
func bulkAddSubscriptions(_ channels: [(id: String, name: String)]) {
|
||||
var addedCount = 0
|
||||
|
||||
for channel in channels {
|
||||
let channelID = channel.id
|
||||
let descriptor = FetchDescriptor<Subscription>(
|
||||
predicate: #Predicate { $0.channelID == channelID }
|
||||
)
|
||||
|
||||
do {
|
||||
let existing = try modelContext.fetch(descriptor)
|
||||
guard existing.isEmpty else {
|
||||
continue
|
||||
}
|
||||
|
||||
let subscription = Subscription(
|
||||
channelID: channel.id,
|
||||
sourceRawValue: "youtube",
|
||||
instanceURLString: nil,
|
||||
name: channel.name
|
||||
)
|
||||
modelContext.insert(subscription)
|
||||
addedCount += 1
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if addedCount > 0 {
|
||||
save()
|
||||
SubscriptionFeedCache.shared.invalidate()
|
||||
LoggingService.shared.info("Bulk added \(addedCount) subscriptions", category: .general)
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if subscribed to a channel.
|
||||
func isSubscribed(to channelID: String) -> Bool {
|
||||
let descriptor = FetchDescriptor<Subscription>(
|
||||
@@ -257,40 +166,6 @@ extension DataManager {
|
||||
// Note: caller is responsible for calling save() after batch operations
|
||||
}
|
||||
|
||||
/// Removes subscriptions matching the given channel IDs.
|
||||
func removeSubscriptions(matching channelIDs: Set<String>) {
|
||||
let allSubscriptions = subscriptions()
|
||||
var removedCount = 0
|
||||
var deleteInfo: [(channelID: String, scope: SourceScope)] = []
|
||||
|
||||
for subscription in allSubscriptions {
|
||||
if channelIDs.contains(subscription.channelID) {
|
||||
// Capture scope before deleting
|
||||
let scope = SourceScope.from(
|
||||
sourceRawValue: subscription.sourceRawValue,
|
||||
globalProvider: subscription.providerName,
|
||||
instanceURLString: subscription.instanceURLString,
|
||||
externalExtractor: nil
|
||||
)
|
||||
deleteInfo.append((subscription.channelID, scope))
|
||||
modelContext.delete(subscription)
|
||||
removedCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
if removedCount > 0 {
|
||||
save()
|
||||
|
||||
// Queue CloudKit deletions
|
||||
for info in deleteInfo {
|
||||
cloudKitSync?.queueSubscriptionDelete(channelID: info.channelID, scope: info.scope)
|
||||
}
|
||||
|
||||
SubscriptionFeedCache.shared.invalidate()
|
||||
LoggingService.shared.info("Removed \(removedCount) test subscriptions", category: .general)
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes all locally stored subscriptions, including their iCloud copies.
|
||||
/// Server-account subscriptions (Invidious/Piped) are unaffected.
|
||||
func deleteAllSubscriptions() {
|
||||
|
||||
Reference in New Issue
Block a user