@@ -11,7 +11,6 @@ import Combine
1111extension Knock {
1212 public class InAppFeedViewModel : ObservableObject {
1313 @Published public var feed : Knock . Feed = Knock . Feed ( ) /// The current feed data.
14- @Published public var currentTenantId : String ? /// The tenant ID associated with the current feed.
1514 @Published public var filterOptions : [ InAppFeedFilter ] /// Available filter options for the feed.
1615 @Published public var topButtonActions : [ Knock . FeedTopActionButtonType ] ? /// Actions available at the top of the feed interface.
1716 @Published internal var brandingRequired : Bool = true
@@ -23,8 +22,8 @@ extension Knock {
2322 }
2423
2524 public var feedClientOptions : Knock . FeedClientOptions /// Configuration options for feed.
26- public let didTapFeedItemButtonPublisher = PassthroughSubject < String , Never > ( ) /// Publisher for feed item button tap events.
27- public let didTapFeedItemRowPublisher = PassthroughSubject < Knock . FeedItem , Never > ( ) /// Publisher for feed item row tap events.
25+ public var didTapFeedItemButtonPublisher = PassthroughSubject < String , Never > ( ) /// Publisher for feed item button tap events.
26+ public var didTapFeedItemRowPublisher = PassthroughSubject < Knock . FeedItem , Never > ( ) /// Publisher for feed item row tap events.
2827
2928 public var shouldHideArchived : Bool {
3029 ( feedClientOptions. archived == . exclude || feedClientOptions. archived == nil )
@@ -36,19 +35,15 @@ extension Knock {
3635
3736 public init (
3837 feedClientOptions: Knock . FeedClientOptions = . init( ) ,
39- currentTenantId: String ? = nil ,
4038 currentFilter: InAppFeedFilter ? = nil ,
4139 filterOptions: [ InAppFeedFilter ] ? = nil ,
4240 topButtonActions: [ Knock . FeedTopActionButtonType ] ? = [ . markAllAsRead( ) , . archiveRead( ) ]
4341 ) {
4442 self . feedClientOptions = feedClientOptions
45- self . currentTenantId = currentTenantId ?? feedClientOptions. tenant
4643 self . filterOptions = filterOptions ?? [ . init( scope: . all) , . init( scope: . unread) , . init( scope: . archived) ]
4744 self . currentFilter = currentFilter ?? filterOptions? . first ?? . init( scope: . all)
4845 self . topButtonActions = topButtonActions
49-
5046 self . feedClientOptions. status = self . currentFilter. scope
51- self . feedClientOptions. tenant = self . currentTenantId
5247 }
5348
5449 // MARK: Public Methods
@@ -129,7 +124,7 @@ extension Knock {
129124 default : break
130125 }
131126
132- let feedOptions = Knock . FeedClientOptions ( status: archivedScope, tenant: currentTenantId , has_tenant: feedClientOptions. has_tenant, archived: feedClientOptions. archived)
127+ let feedOptions = Knock . FeedClientOptions ( status: archivedScope, tenant: feedClientOptions . tenant , has_tenant: feedClientOptions. has_tenant, archived: feedClientOptions. archived)
133128 do {
134129 _ = try await Knock . shared. feedManager? . makeBulkStatusUpdate ( type: updatedStatus, options: feedOptions)
135130 await optimisticallyBulkUpdateStatus ( updatedStatus: updatedStatus, archivedScope: archivedScope)
@@ -142,7 +137,7 @@ extension Knock {
142137 switch updatedStatus {
143138 case . seen: guard item. seen_at == nil else { return }
144139 case . read: guard item. read_at == nil else { return }
145- case . interacted: guard item. inserted_at == nil else { return }
140+ case . interacted: guard item. interacted_at == nil else { return }
146141 case . archived: guard item. archived_at == nil else { return }
147142 case . unread: guard item. read_at != nil else { return }
148143 case . unseen: guard item. seen_at != nil else { return }
@@ -173,12 +168,11 @@ extension Knock {
173168
174169 // MARK: Button/Swipe Interactions
175170
176- public func didSwipeRow( item: Knock . FeedItem , swipeAction: FeedNotificationRowSwipeAction ) {
171+ public func didSwipeRow( item: Knock . FeedItem , swipeAction: FeedNotificationRowSwipeAction , useInverse : Bool ) {
177172 Task {
178173 switch swipeAction {
179- case . archive: await updateMessageEngagementStatus ( item, updatedStatus: . archived)
180- case . markAsRead: await updateMessageEngagementStatus ( item, updatedStatus: . read)
181- case . markAsUnread: await updateMessageEngagementStatus ( item, updatedStatus: . unread)
174+ case . archive: await updateMessageEngagementStatus ( item, updatedStatus: useInverse ? . unarchived : . archived)
175+ case . markAsRead: await updateMessageEngagementStatus ( item, updatedStatus: useInverse ? . unread : . read)
182176 }
183177 }
184178 }
@@ -249,7 +243,7 @@ extension Knock {
249243
250244 private func shouldArchive( item: Knock . FeedItem , scope: Knock . FeedItemScope ) -> Bool {
251245 switch scope {
252- case . interacted: return item. inserted_at != nil
246+ case . interacted: return item. interacted_at != nil
253247 case . unread: return item. read_at == nil
254248 case . read: return item. read_at != nil
255249 case . unseen: return item. seen_at == nil
0 commit comments