From 57894754a6d9cdd5b2f5eb531eda4c2646f9669c Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 20 Jul 2023 13:12:48 +0800 Subject: [PATCH] Add MainActor to main views in iOS --- apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift | 2 ++ apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift | 1 + apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift | 2 ++ apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift | 1 + 4 files changed, 6 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index e78cc07d9..79d85f167 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -23,6 +23,7 @@ struct AnimatingCellHeight: AnimatableModifier { #if os(iOS) private let enableGrid = UIDevice.isIPad || FeatureFlag.enableGridCardsOnPhone + @MainActor struct HomeFeedContainerView: View { @State var hasHighlightMutations = false @State var searchPresented = false @@ -228,6 +229,7 @@ struct AnimatingCellHeight: AnimatableModifier { } } + @MainActor struct HomeFeedView: View { @EnvironmentObject var dataService: DataService @Binding var prefersListLayout: Bool diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift index ff9cb9c47..f0817bcbd 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift @@ -2,6 +2,7 @@ import SwiftUI import Utils import Views +@MainActor struct HomeView: View { @State private var viewModel: HomeFeedViewModel diff --git a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift index 6f12bd209..a4476520e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift @@ -7,6 +7,7 @@ import Views let appLogger = Logger(subsystem: "app.omnivore", category: "app-package") +@MainActor public struct RootView: View { @Environment(\.scenePhase) var scenePhase @StateObject private var viewModel = RootViewModel() @@ -39,6 +40,7 @@ public struct RootView: View { } } +@MainActor struct InnerRootView: View { @EnvironmentObject var dataService: DataService @EnvironmentObject var authenticator: Authenticator diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift index 9c8e27b66..34cea7e21 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReader.swift @@ -4,6 +4,7 @@ import Utils import Views import WebKit +@MainActor struct WebReader: PlatformViewRepresentable { let item: LinkedItem let articleContent: ArticleContent