mirror of
https://github.com/yattee/yattee.git
synced 2026-07-20 14:22:02 +00:00
Remove media sources as Home sections (shortcuts-only)
A media-source "section" only rendered as a full-width "Browse {name}"
link, identical for all source types and redundant with the shortcut
card. Remove it from the Available Sections add-list and clean up any
already-added media-source sections on load.
Keep HomeSectionItem.mediaSource as a decode-only case so existing saved
homeSectionOrder data (decoded all-or-nothing) still parses; strip those
entries via removeAllHomeMediaSourceSections(). Media-source shortcuts
are unchanged.
This commit is contained in:
@@ -586,13 +586,6 @@ extension SettingsManager {
|
||||
return existingCards.contains(card.id) ? [] : [card]
|
||||
}
|
||||
|
||||
/// Returns all available section items for a media source that are NOT already added.
|
||||
func availableSections(for source: MediaSource) -> [HomeSectionItem] {
|
||||
let section = HomeSectionItem.mediaSource(sourceID: source.id)
|
||||
let existingSections = Set(homeSectionOrder.map { $0.id })
|
||||
return existingSections.contains(section.id) ? [] : [section]
|
||||
}
|
||||
|
||||
/// Returns all available cards across all media sources, grouped by source.
|
||||
func allAvailableMediaSourceShortcuts(sources: [MediaSource]) -> [(source: MediaSource, cards: [HomeShortcutItem])] {
|
||||
sources.compactMap { source in
|
||||
@@ -601,14 +594,6 @@ extension SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all available sections across all media sources, grouped by source.
|
||||
func allAvailableMediaSourceSections(sources: [MediaSource]) -> [(source: MediaSource, sections: [HomeSectionItem])] {
|
||||
sources.compactMap { source in
|
||||
let sections = availableSections(for: source)
|
||||
return sections.isEmpty ? nil : (source, sections)
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes all Home items for media sources that no longer exist.
|
||||
func cleanupOrphanedHomeMediaSourceItems(validSourceIDs: Set<UUID>) {
|
||||
var hadOrphans = false
|
||||
@@ -682,6 +667,45 @@ extension SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes ALL media-source Home *sections* (regardless of whether the source
|
||||
/// still exists). Media sources are shortcuts-only now — a media-source
|
||||
/// "section" was just a browse link and the feature was removed. Idempotent:
|
||||
/// only writes when something changed, so it's safe to call on every load and
|
||||
/// it also cleans up media-source sections that sync in from an older device.
|
||||
/// Leaves media-source *shortcuts* (`homeShortcutOrder`/`homeShortcutVisibility`) untouched.
|
||||
func removeAllHomeMediaSourceSections() {
|
||||
var didChange = false
|
||||
|
||||
var sectionOrder = homeSectionOrder
|
||||
let originalCount = sectionOrder.count
|
||||
sectionOrder.removeAll { item in
|
||||
if case .mediaSource = item { return true }
|
||||
return false
|
||||
}
|
||||
if sectionOrder.count != originalCount {
|
||||
LoggingService.shared.logCloudKit("removeAllHomeMediaSourceSections: removed \(originalCount - sectionOrder.count) media-source sections")
|
||||
homeSectionOrder = sectionOrder
|
||||
didChange = true
|
||||
}
|
||||
|
||||
var sectionVis = homeSectionVisibility
|
||||
let orphanedKeys = sectionVis.keys.filter { item in
|
||||
if case .mediaSource = item { return true }
|
||||
return false
|
||||
}
|
||||
if !orphanedKeys.isEmpty {
|
||||
for key in orphanedKeys {
|
||||
sectionVis.removeValue(forKey: key)
|
||||
}
|
||||
homeSectionVisibility = sectionVis
|
||||
didChange = true
|
||||
}
|
||||
|
||||
if didChange {
|
||||
LoggingService.shared.logCloudKit("removeAllHomeMediaSourceSections: cleaned up media-source sections")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tab Bar Settings (Compact Size Class)
|
||||
|
||||
/// Ordered list of tab bar items. Default order is subscriptions first, then others.
|
||||
|
||||
Reference in New Issue
Block a user