diff --git a/animeal/src/Flows/Main/Modules/Home/Main/HomeContract.swift b/animeal/src/Flows/Main/Modules/Home/Main/HomeContract.swift index e0c5c023..ceec65e5 100644 --- a/animeal/src/Flows/Main/Modules/Home/Main/HomeContract.swift +++ b/animeal/src/Flows/Main/Modules/Home/Main/HomeContract.swift @@ -30,6 +30,7 @@ protocol HomeModelProtocol: AnyObject { func processCancelFeeding() async throws -> FeedingResponse func processFinishFeeding(imageKeys: [String]) async throws -> FeedingResponse func fetchFeedingSnapshot() -> FeedingSnapshot? + func updateFeedingSnapshot(id: String, date: Date) @discardableResult func processRejectFeeding() async throws -> FeedingResponse func fetchActiveFeeding() async throws -> Feeding? diff --git a/animeal/src/Flows/Main/Modules/Home/Main/HomeViewModel.swift b/animeal/src/Flows/Main/Modules/Home/Main/HomeViewModel.swift index f16cb40f..274a6b0f 100644 --- a/animeal/src/Flows/Main/Modules/Home/Main/HomeViewModel.swift +++ b/animeal/src/Flows/Main/Modules/Home/Main/HomeViewModel.swift @@ -132,6 +132,9 @@ final class HomeViewModel: HomeViewModelLifeCycle, HomeViewInteraction, HomeView return false } do { + let creationDate = activeFeeding.createdAt.foundationDate + model.updateFeedingSnapshot(id: activeFeeding.feedingPointFeedingsId, date: creationDate) + let snapshotTimeDiff = model.fetchFeedingSnapshot()?.startingTimeDiff ?? NetTime.serverTimeDifference let timeDiff = snapshotTimeDiff - NetTime.serverTimeDifference let feedingPoint = try await model.fetchFeedingPoint(activeFeeding.feedingPointFeedingsId) diff --git a/animeal/src/Flows/Main/Modules/Home/Main/Model/HomeModel.swift b/animeal/src/Flows/Main/Modules/Home/Main/Model/HomeModel.swift index c5f25f8d..6dc828e5 100644 --- a/animeal/src/Flows/Main/Modules/Home/Main/Model/HomeModel.swift +++ b/animeal/src/Flows/Main/Modules/Home/Main/Model/HomeModel.swift @@ -115,6 +115,10 @@ final class HomeModel: HomeModelProtocol { func fetchFeedingSnapshot() -> FeedingSnapshot? { return snapshotStore.snaphot } + + func updateFeedingSnapshot(id: String, date: Date) { + snapshotStore.save(id, date: date) + } @discardableResult func processCancelFeeding() async throws -> FeedingResponse {