From 6bb2a0b42a99bf43e58995c23cc81d8c74d10642 Mon Sep 17 00:00:00 2001 From: yungu0010 Date: Thu, 27 Jun 2024 03:38:44 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#252=20-=2000=EC=8B=9C=EC=97=90=20AppGr?= =?UTF-8?q?oup=EC=9D=98=20dailyMission=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS-NOTTODO/Widget-NOTTODO/Provider/MissionProvider.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iOS-NOTTODO/Widget-NOTTODO/Provider/MissionProvider.swift b/iOS-NOTTODO/Widget-NOTTODO/Provider/MissionProvider.swift index 0beabfa..9bf53dd 100644 --- a/iOS-NOTTODO/Widget-NOTTODO/Provider/MissionProvider.swift +++ b/iOS-NOTTODO/Widget-NOTTODO/Provider/MissionProvider.swift @@ -13,7 +13,7 @@ struct Provider: AppIntentTimelineProvider { @AppStorage("quote", store: UserDefaults.shared) var quote: String = "" func placeholder(in context: Context) -> SimpleEntry { - SimpleEntry(todayMission: [], quote: "") + SimpleEntry(todayMission: [], quote: quote) } func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { @@ -34,6 +34,7 @@ struct Provider: AppIntentTimelineProvider { if now == midnightToday { try await getQuote() + try await getDailyMission(date: Formatter.dateFormatterString(format: nil, date: now)) } guard let decodedData = try? JSONDecoder().decode([DailyMissionResponseDTO].self, from: sharedData) else { @@ -52,4 +53,9 @@ struct Provider: AppIntentTimelineProvider { let quoteResponse = try await WidgetService.shared.fetchWiseSaying() quote = quoteResponse.description + " - " + quoteResponse.author } + + private func getDailyMission(date: String) async throws { + let dailyMission = try await WidgetService.shared.fetchDailyMissoin(date: date) + UserDefaults.shared?.setSharedCustomArray(dailyMission, forKey: "dailyMission") + } }