removed unwanted bar now with waveforms, major updates
This commit is contained in:
@@ -360,7 +360,15 @@ struct NameTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
extension AppModel {
|
||||
@MainActor protocol NameReinterpretationModel: ObservableObject {
|
||||
var songs: [Song] { get }
|
||||
var library: Library? { get }
|
||||
var namesBusy: Bool { get }
|
||||
func refresh() throws
|
||||
func perform(_ action: () throws -> Void)
|
||||
func applyNameChanges(_ changes: [NameChange]) async throws
|
||||
}
|
||||
extension NameReinterpretationModel {
|
||||
func savedNameTemplates() -> [String] {
|
||||
let saved = ((try? library?.setting(NameTemplate.settingsKey)) ?? "").components(separatedBy:"\n").filter{!$0.trimmingCharacters(in:.whitespaces).isEmpty}
|
||||
return Array(Set(NameTemplate.presets+saved)).sorted()
|
||||
@@ -371,6 +379,8 @@ extension AppModel {
|
||||
for (index,template) in templates.enumerated() { do { _ = try NameTemplate(template) } catch { throw LibraryError.message("Line \(index+1): \(error.localizedDescription)") } }
|
||||
try library?.setSetting(NameTemplate.settingsKey,templates.joined(separator:"\n"))
|
||||
}
|
||||
}
|
||||
extension AppModel: NameReinterpretationModel {
|
||||
func applyNameChanges(_ changes:[NameChange]) async throws {
|
||||
guard !namesBusy,!isImporting,!movingMedia,scanningSource == nil,!generatingWaveforms,!tagsBusy else { throw LibraryError.message("Finish the current library job first") }
|
||||
namesBusy = true;defer { namesBusy = false }
|
||||
@@ -389,8 +399,8 @@ extension AppModel {
|
||||
}
|
||||
}
|
||||
|
||||
struct ReinterpretNamesSheet: View {
|
||||
@ObservedObject var model: AppModel
|
||||
struct ReinterpretNamesSheet<Model: NameReinterpretationModel>: View {
|
||||
@ObservedObject var model: Model
|
||||
let ids: Set<Int64>
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var template = "L-T - R - S"
|
||||
@@ -482,3 +492,22 @@ extension FocusedValues {
|
||||
set { self[NameReinterpretationKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
extension DJSystem: NameReinterpretationModel {
|
||||
func applyNameChanges(_ changes: [NameChange]) async throws {
|
||||
guard !namesBusy,!importing,!generatingWaveforms else { throw LibraryError.message("Finish the current library job first") }
|
||||
namesBusy = true;defer { namesBusy = false }
|
||||
let database = root.appendingPathComponent("Library.sqlite")
|
||||
_ = try await Task.detached(priority:.utility) { try Library(url:database).reinterpretNames(changes) }.value
|
||||
try refresh()
|
||||
for deck in [a,b] { if let song = songs.first(where:{$0.id == deck.song?.id}) { deck.updateTrackMetadata(song) } }
|
||||
}
|
||||
func undoNameChanges() async throws {
|
||||
guard !namesBusy,!importing,!generatingWaveforms else { throw LibraryError.message("Finish the current library job first") }
|
||||
namesBusy = true;defer { namesBusy = false }
|
||||
let database = root.appendingPathComponent("Library.sqlite")
|
||||
_ = try await Task.detached(priority:.utility) { try Library(url:database).undoNameReinterpretation() }.value
|
||||
try refresh()
|
||||
for deck in [a,b] { if let song = songs.first(where:{$0.id == deck.song?.id}) { deck.updateTrackMetadata(song) } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user