From 958c6391e8ebf47574280b01607e44fb743e9a1b Mon Sep 17 00:00:00 2001 From: Robbe Van Petegem Date: Sun, 14 May 2023 13:57:12 +0200 Subject: [PATCH] Allow users to refresh data through commands (#43) --- accentor/accentorApp.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/accentor/accentorApp.swift b/accentor/accentorApp.swift index c3b37e7..a34c3ca 100644 --- a/accentor/accentorApp.swift +++ b/accentor/accentorApp.swift @@ -16,5 +16,17 @@ struct accentorApp: App { ContentView() .environment(\.managedObjectContext, persistenceController.container.viewContext) } + .commands { + CommandMenu("Data") { + Button(action: { + AlbumService.shared.index(context: persistenceController.container.viewContext) + ArtistService.shared.index(context: persistenceController.container.viewContext) + TrackService.shared.index(context: persistenceController.container.viewContext) + UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: "last_sync_finished") + }, label: { + Text("Refresh") + }) + } + } } }