From 91c294f9c878e8d4c33c65b1750eaac344d5f197 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 15 Feb 2022 11:45:45 -0800 Subject: [PATCH] use a snozzeActionParams struct to pass values --- .../PrimaryContainerViews/HomeFeedView.swift | 4 ++-- apple/OmnivoreKit/Sources/Views/SnoozeView.swift | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift index f7066c59a..5c61c17c4 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift +++ b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift @@ -239,9 +239,9 @@ public struct HomeFeedView: View { } } .formSheet(isPresented: $snoozePresented) { - SnoozeView(snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze) { linkId, until, successMessage in + SnoozeView(snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze) { viewModel.performActionSubject.send( - .snooze(linkId: linkId, until: until, successMessage: successMessage) + .snooze(linkId: $0.feedItemId, until: $0.snoozeUntilDate, successMessage: $0.successMessage) ) } } diff --git a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift index e126f80d2..63b1c91c6 100644 --- a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift +++ b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift @@ -4,7 +4,7 @@ import SwiftUI struct SnoozeView: View { @Binding var snoozePresented: Bool @Binding var itemToSnooze: FeedItem? - let snoozeAction: (String, Date, String?) -> Void + let snoozeAction: (SnoozeActionParams) -> Void var body: some View { VStack { @@ -28,7 +28,13 @@ struct SnoozeView: View { private func snoozeItem(_ snooze: Snooze) { if let item = itemToSnooze { withAnimation(.linear(duration: 0.4)) { - snoozeAction(item.id, snooze.until, "Snoozed until \(snooze.untilStr)") + snoozeAction( + SnoozeActionParams( + feedItemId: item.id, + snoozeUntilDate: snooze.until, + successMessage: "Snoozed until \(snooze.untilStr)" + ) + ) } } itemToSnooze = nil @@ -36,6 +42,12 @@ struct SnoozeView: View { } } +struct SnoozeActionParams { + let feedItemId: String + let snoozeUntilDate: Date + let successMessage: String? +} + private struct SnoozeIconButtonView: View { let snooze: Snooze let action: (_ snooze: Snooze) -> Void