diff --git a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift index c1fde6ec3..712d19be3 100644 --- a/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/PDFSupport/PDFViewerViewModel.swift @@ -7,12 +7,12 @@ public final class PDFViewerViewModel: ObservableObject { @Published public var errorMessage: String? @Published public var readerView: Bool = false - public var feedItem: FeedItem + public var feedItem: FeedItemDep var subscriptions = Set() let services: Services - public init(services: Services, feedItem: FeedItem) { + public init(services: Services, feedItem: FeedItemDep) { self.services = services self.feedItem = feedItem } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift index dbf0084ca..14e3ccca8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift @@ -6,7 +6,7 @@ import Views struct FeedCardNavigationLink: View { @EnvironmentObject var dataService: DataService - let item: FeedItem + let item: FeedItemDep @ObservedObject var viewModel: HomeFeedViewModel @@ -34,7 +34,7 @@ struct GridCardNavigationLink: View { @State private var scale = 1.0 - let item: FeedItem + let item: FeedItemDep let actionHandler: (GridCardAction) -> Void @Binding var isContextMenuOpen: Bool diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 46720c206..343503e49 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -58,7 +58,7 @@ import Views } } .onReceive(NotificationCenter.default.publisher(for: Notification.Name("PushFeedItem"))) { notification in - if let feedItem = notification.userInfo?["feedItem"] as? FeedItem { + if let feedItem = notification.userInfo?["feedItem"] as? FeedItemDep { viewModel.pushFeedItem(item: feedItem) viewModel.selectedLinkItem = feedItem } @@ -145,7 +145,7 @@ import Views @EnvironmentObject var dataService: DataService @Binding var prefersListLayout: Bool - @State private var itemToRemove: FeedItem? + @State private var itemToRemove: FeedItemDep? @State private var confirmationShown = false @ObservedObject var viewModel: HomeFeedViewModel @@ -269,13 +269,13 @@ import Views struct HomeFeedGridView: View { @EnvironmentObject var dataService: DataService - @State private var itemToRemove: FeedItem? + @State private var itemToRemove: FeedItemDep? @State private var confirmationShown = false @State var isContextMenuOpen = false @ObservedObject var viewModel: HomeFeedViewModel - func contextMenuActionHandler(item: FeedItem, action: GridCardAction) { + func contextMenuActionHandler(item: FeedItemDep, action: GridCardAction) { switch action { case .toggleArchiveStatus: viewModel.setLinkArchived(dataService: dataService, linkId: item.id, archived: !item.isArchived) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index 3ca413ff5..6f17a64cb 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -9,7 +9,7 @@ import Views #if os(macOS) struct HomeFeedView: View { @EnvironmentObject var dataService: DataService - @State private var itemToRemove: FeedItem? + @State private var itemToRemove: FeedItemDep? @State private var confirmationShown = false @ObservedObject var viewModel: HomeFeedViewModel diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index d2d052fb8..b20389a81 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -14,15 +14,15 @@ import Views /// Track label updates to be committed when user navigates back to grid view var uncommittedLabelUpdates = [String: [FeedItemLabelDep]]() - @Published var items = [FeedItem]() + @Published var items = [FeedItemDep]() @Published var isLoading = false @Published var showPushNotificationPrimer = false - @Published var itemUnderLabelEdit: FeedItem? + @Published var itemUnderLabelEdit: FeedItemDep? @Published var searchTerm = "" @Published var selectedLabels = [FeedItemLabelDep]() @Published var snoozePresented = false - @Published var itemToSnooze: FeedItem? - @Published var selectedLinkItem: FeedItem? + @Published var itemToSnooze: FeedItemDep? + @Published var selectedLinkItem: FeedItemDep? var cursor: String? var sendProgressUpdates = false @@ -36,7 +36,7 @@ import Views init() {} - func itemAppeared(item: FeedItem, dataService: DataService) { + func itemAppeared(item: FeedItemDep, dataService: DataService) { if isLoading { return } let itemIndex = items.firstIndex(where: { $0.id == item.id }) let thresholdIndex = items.index(items.endIndex, offsetBy: -5) @@ -47,7 +47,7 @@ import Views } } - func pushFeedItem(item: FeedItem) { + func pushFeedItem(item: FeedItemDep) { items.insert(item, at: 0) } diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift index 8e2fa47f1..99ffb4446 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift @@ -5,7 +5,7 @@ import Views struct ApplyLabelsView: View { enum Mode { - case item(FeedItem) + case item(FeedItemDep) case list([FeedItemLabelDep]) var navTitle: String { diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift index d35f3c9d7..729f72f13 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/LabelsViewModel.swift @@ -19,7 +19,7 @@ final class LabelsViewModel: ObservableObject { /// - dataService: `DataService` reference /// - item: Optional `FeedItem` for applying labels to a single item /// - initiallySelectedLabels: Optional `[FeedItemLabel]` for filtering a list of items - func loadLabels(dataService: DataService, item: FeedItem? = nil, initiallySelectedLabels: [FeedItemLabelDep]? = nil) { + func loadLabels(dataService: DataService, item: FeedItemDep? = nil, initiallySelectedLabels: [FeedItemLabelDep]? = nil) { guard !hasLoadedInitialLabels else { return } isLoading = true diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index a3de5f6a8..dc30ef228 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -6,17 +6,17 @@ import Utils import Views enum PDFProvider { - static var pdfViewerProvider: ((URL, FeedItem) -> AnyView)? + static var pdfViewerProvider: ((URL, FeedItemDep) -> AnyView)? } @MainActor final class LinkItemDetailViewModel: ObservableObject { let homeFeedViewModel: HomeFeedViewModel - @Published var item: FeedItem + @Published var item: FeedItemDep @Published var webAppWrapperViewModel: WebAppWrapperViewModel? var subscriptions = Set() - init(item: FeedItem, homeFeedViewModel: HomeFeedViewModel) { + init(item: FeedItemDep, homeFeedViewModel: HomeFeedViewModel) { self.item = item self.homeFeedViewModel = homeFeedViewModel } diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index c7c678c2e..e38dd8c95 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -7,7 +7,7 @@ import WebKit #if os(iOS) struct WebReader: UIViewRepresentable { let articleContent: ArticleContentDep - let item: FeedItem + let item: FeedItemDep let openLinkAction: (URL) -> Void let webViewActionHandler: (WKScriptMessage, WKScriptMessageReplyHandler?) -> Void let navBarVisibilityRatioUpdater: (Double) -> Void diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index d0c8cf42d..dbfadd324 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -7,7 +7,7 @@ import WebKit #if os(iOS) struct WebReaderContainerView: View { - let item: FeedItem + let item: FeedItemDep let homeFeedViewModel: HomeFeedViewModel @State private var showFontSizePopover = false diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift index 8414c374d..42a2f1a26 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContent.swift @@ -5,12 +5,12 @@ import Utils struct WebReaderContent { let textFontSize: Int let articleContent: ArticleContentDep - let item: FeedItem + let item: FeedItemDep let themeKey: String init( articleContent: ArticleContentDep, - item: FeedItem, + item: FeedItemDep, isDark: Bool, fontSize: Int ) { diff --git a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift index f7618d6bc..9970f1c63 100644 --- a/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift +++ b/apple/OmnivoreKit/Sources/Models/DataModels/FeedItem.swift @@ -1,16 +1,16 @@ import Foundation public struct HomeFeedData { - public let items: [FeedItem] + public let items: [FeedItemDep] public let cursor: String? - public init(items: [FeedItem], cursor: String?) { + public init(items: [FeedItemDep], cursor: String?) { self.items = items self.cursor = cursor } } -public struct FeedItem: Identifiable, Hashable { +public struct FeedItemDep: Identifiable, Hashable { public let id: String public let title: String public let createdAt: Date @@ -70,7 +70,7 @@ public struct FeedItem: Identifiable, Hashable { self.labels = labels } - public static func fromJsonArticle(linkData: Data) -> FeedItem? { + public static func fromJsonArticle(linkData: Data) -> FeedItemDep? { try? JSONDecoder().decode(JSONArticle.self, from: linkData).feedItem } @@ -114,8 +114,8 @@ struct JSONArticle: Decodable { let url: String let isArchived: Bool - var feedItem: FeedItem { - FeedItem( + var feedItem: FeedItemDep { + FeedItemDep( id: id, title: title, createdAt: createdAt, diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index de32ddbd2..08e39f1aa 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -63,7 +63,7 @@ public final class DataService: ObservableObject { } public extension DataService { - func prefetchPages(items: [FeedItem]) { + func prefetchPages(items: [FeedItemDep]) { guard let username = currentViewer?.username else { return } for item in items { diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift index 93ccf5c64..130541350 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Mutations/UpdateArticleReadingProgress.swift @@ -8,9 +8,9 @@ public extension DataService { itemID: String, readingProgress: Double, anchorIndex: Int - ) -> AnyPublisher { + ) -> AnyPublisher { enum MutationResult { - case saved(feedItem: FeedItem) + case saved(feedItem: FeedItemDep) case error(errorCode: Enums.SaveArticleReadingProgressErrorCode) } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift index d6f31e93c..e43d63efb 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/Queries/LibraryItemsQuery.swift @@ -4,7 +4,7 @@ import Models import SwiftGraphQL public extension DataService { - func articlePublisher(slug: String) -> AnyPublisher { + func articlePublisher(slug: String) -> AnyPublisher { internalViewerPublisher() .flatMap { self.internalArticlePublisher(username: $0.username ?? "", slug: slug) } .receive(on: DispatchQueue.main) @@ -13,9 +13,9 @@ public extension DataService { } extension DataService { - func internalArticlePublisher(username: String, slug: String) -> AnyPublisher { + func internalArticlePublisher(username: String, slug: String) -> AnyPublisher { enum QueryResult { - case success(result: FeedItem) + case success(result: FeedItemDep) case error(error: String) } @@ -126,7 +126,7 @@ public extension DataService { } let homeFeedItemSelection = Selection.Article { - FeedItem( + FeedItemDep( id: try $0.id(), title: try $0.title(), createdAt: try $0.createdAt().value ?? Date(), diff --git a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift index c7fdd5682..0aad9b201 100644 --- a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift +++ b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift @@ -32,7 +32,7 @@ public extension NSNotification { return nil } - static func pushFeedItem(feedItem: FeedItem) { + static func pushFeedItem(feedItem: FeedItemDep) { NotificationCenter.default.post(name: NSNotification.PushFeedItem, object: nil, userInfo: ["feedItem": feedItem]) } diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift index 3d75ed4b0..a10a29459 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/GridCard.swift @@ -10,12 +10,12 @@ public enum GridCardAction { public struct GridCard: View { @Binding var isContextMenuOpen: Bool - let item: FeedItem + let item: FeedItemDep let actionHandler: (GridCardAction) -> Void let tapAction: () -> Void public init( - item: FeedItem, + item: FeedItemDep, isContextMenuOpen: Binding, actionHandler: @escaping (GridCardAction) -> Void, tapAction: @escaping () -> Void diff --git a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift index 5ae355eea..3c437557b 100644 --- a/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift +++ b/apple/OmnivoreKit/Sources/Views/FeedItem/HomeFeedCardView.swift @@ -3,9 +3,9 @@ import SwiftUI import Utils public struct FeedCard: View { - let item: FeedItem + let item: FeedItemDep - public init(item: FeedItem) { + public init(item: FeedItemDep) { self.item = item } diff --git a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift index 8c23a926e..4b495efe8 100644 --- a/apple/OmnivoreKit/Sources/Views/SnoozeView.swift +++ b/apple/OmnivoreKit/Sources/Views/SnoozeView.swift @@ -3,12 +3,12 @@ import SwiftUI public struct SnoozeView: View { @Binding var snoozePresented: Bool - @Binding var itemToSnooze: FeedItem? + @Binding var itemToSnooze: FeedItemDep? let snoozeAction: (SnoozeActionParams) -> Void public init( snoozePresented: Binding, - itemToSnooze: Binding, + itemToSnooze: Binding, snoozeAction: @escaping (SnoozeActionParams) -> Void ) { self._snoozePresented = snoozePresented diff --git a/apple/Sources/PushNotificationConfig.swift b/apple/Sources/PushNotificationConfig.swift index 7927cbd6f..96e68e557 100644 --- a/apple/Sources/PushNotificationConfig.swift +++ b/apple/Sources/PushNotificationConfig.swift @@ -57,7 +57,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate { let userInfo = response.notification.request.content.userInfo if let linkData = userInfo["link"] as? String { guard let jsonData = Data(base64Encoded: linkData) else { return } - if let item = FeedItem.fromJsonArticle(linkData: jsonData) { + if let item = FeedItemDep.fromJsonArticle(linkData: jsonData) { NSNotification.pushFeedItem(feedItem: item) } }