From c84737a1a63112a697d3cc6fa8465e7fa841d44f Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 8 Aug 2022 08:47:51 -0700 Subject: [PATCH] clear last sync time value when resetting core data --- .../Sources/App/Views/Home/HomeFeedViewModel.swift | 1 - .../Sources/Services/DataService/DataService.swift | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 5f721053e..ac7e4e7e5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -29,7 +29,6 @@ import Views @Published var appliedSort = LinkedItemSort.newest.rawValue // @AppStorage(UserDefaultKey.lastSelectedLinkedItemFilter.rawValue) // TODO: missing value here? - // TODO: delete this value when needed (logout, clear core data, new app version @AppStorage(UserDefaultKey.lastItemSyncTime.rawValue) var lastItemSyncTime = DateFormatter.formatterISO8601.string(from: Date( timeIntervalSinceReferenceDate: 0 )) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index 64d58fb33..1d65dd84e 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -96,6 +96,11 @@ public final class DataService: ObservableObject { } func resetCoreData() { + UserDefaults.standard.set( + DateFormatter.formatterISO8601.string(from: Date(timeIntervalSinceReferenceDate: 0)), + forKey: UserDefaultKey.lastItemSyncTime.rawValue + ) + clearCoreData() persistentContainer = PersistentContainer.make()