From 2c573c6f792c24e5c8bfa1439b73559716512278 Mon Sep 17 00:00:00 2001 From: Jason Morley Date: Tue, 20 Jun 2023 19:16:54 -0400 Subject: [PATCH] fix: Remember selected sidebar section across app launches (#676) --- .../Commands/ApplicationCommands.swift | 5 +- .../Commands/BookmarkCommands.swift | 3 +- .../Commands/BookmarkOpenCommands.swift | 6 +- .../Commands/BookmarkTagCommands.swift | 6 +- .../Commands/SectionCommands.swift | 6 +- .../Common/BookmarksSection.swift | 2 +- .../BookmarksCore/Common/Settings.swift | 8 ++ .../Model/BrowserPreferene.swift | 1 - .../{SceneModel.swift => SceneState.swift} | 88 ++++++++++++++----- .../Model/SectionViewModel.swift | 20 ++--- .../Modifiers/SceneActionHandler.swift | 8 +- .../Toolbars/SelectionToolbar.swift | 4 +- .../BookmarksCore/Views/ContentView.swift | 20 ++--- .../Views/MacSectionGridView.swift | 3 +- .../Views/PhoneSectionGridView.swift | 3 +- .../Views/SectionTableView.swift | 5 +- .../BookmarksCore/Views/SectionView.swift | 6 +- .../Sources/BookmarksCore/Views/Sidebar.swift | 12 +-- .../Views/SidebarContentView.swift | 9 +- ios/Bookmarks/BookmarksApp.swift | 1 - macos/Bookmarks/BookmarksApp.swift | 1 - 21 files changed, 130 insertions(+), 87 deletions(-) rename core/Sources/BookmarksCore/Model/{SceneModel.swift => SceneState.swift} (54%) diff --git a/core/Sources/BookmarksCore/Commands/ApplicationCommands.swift b/core/Sources/BookmarksCore/Commands/ApplicationCommands.swift index 8a11cf0e..f8eb62d8 100644 --- a/core/Sources/BookmarksCore/Commands/ApplicationCommands.swift +++ b/core/Sources/BookmarksCore/Commands/ApplicationCommands.swift @@ -22,9 +22,10 @@ import SwiftUI public struct ApplicationCommands: Commands { - @FocusedObject var sceneModel: SceneModel? @Environment(\.openWindow) var openWindow + @FocusedBinding(\.sceneState) var sceneState + public init() { } @@ -35,7 +36,7 @@ public struct ApplicationCommands: Commands { #if os(macOS) openWindow(id: TagsWindow.identifier) #else - sceneModel?.showTags() + sceneState?.showTags() #endif } label: { Text("Tags...") diff --git a/core/Sources/BookmarksCore/Commands/BookmarkCommands.swift b/core/Sources/BookmarksCore/Commands/BookmarkCommands.swift index 86beb0be..6905a9ef 100644 --- a/core/Sources/BookmarksCore/Commands/BookmarkCommands.swift +++ b/core/Sources/BookmarksCore/Commands/BookmarkCommands.swift @@ -22,7 +22,6 @@ import SwiftUI public struct BookmarkCommands: Commands { - @FocusedObject var sceneModel: SceneModel? @FocusedObject var sectionViewModel: SectionViewModel? public init() { @@ -40,7 +39,7 @@ public struct BookmarkCommands: Commands { .trailingDivider() BookmarkShareCommands(sectionViewModel: sectionViewModel ?? SectionViewModel()) .trailingDivider() - BookmarkTagCommands(sceneModel: sceneModel, sectionViewModel: sectionViewModel ?? SectionViewModel()) + BookmarkTagCommands(sectionViewModel: sectionViewModel ?? SectionViewModel()) } } diff --git a/core/Sources/BookmarksCore/Commands/BookmarkOpenCommands.swift b/core/Sources/BookmarksCore/Commands/BookmarkOpenCommands.swift index a2b2646f..e16772be 100644 --- a/core/Sources/BookmarksCore/Commands/BookmarkOpenCommands.swift +++ b/core/Sources/BookmarksCore/Commands/BookmarkOpenCommands.swift @@ -22,12 +22,14 @@ import SwiftUI struct BookmarkOpenCommands: View { + @EnvironmentObject var settings: Settings + @ObservedObject var sectionViewModel: SectionViewModel var body: some View { Button(LocalizedString("BOOKMARK_MENU_TITLE_OPEN")) { - sectionViewModel.open(.selection) + sectionViewModel.open(.selection, browser: settings.browser) } .keyboardShortcut(.return, modifiers: [.command]) .disabled(sectionViewModel.selection.isEmpty) @@ -43,7 +45,7 @@ struct BookmarkOpenCommands: View { Divider() Button(LocalizedString("BOOKMARK_MENU_TITLE_VIEW_ON_INTERNET_ARCHIVE")) { - sectionViewModel.open(.selection, location: .internetArchive) + sectionViewModel.open(.selection, location: .internetArchive, browser: settings.browser) } .keyboardShortcut(.return, modifiers: [.command, .shift]) .disabled(sectionViewModel.selection.isEmpty) diff --git a/core/Sources/BookmarksCore/Commands/BookmarkTagCommands.swift b/core/Sources/BookmarksCore/Commands/BookmarkTagCommands.swift index c88051e2..31619b3c 100644 --- a/core/Sources/BookmarksCore/Commands/BookmarkTagCommands.swift +++ b/core/Sources/BookmarksCore/Commands/BookmarkTagCommands.swift @@ -22,7 +22,7 @@ import SwiftUI struct BookmarkTagCommands: View { - var sceneModel: SceneModel? + @FocusedBinding(\.sceneState) var sceneState @ObservedObject var sectionViewModel: SectionViewModel @@ -31,9 +31,9 @@ struct BookmarkTagCommands: View { ForEach(Array(sectionViewModel.selectionTags).sorted()) { tag in Button(tag) { - sceneModel?.revealTag(tag) + sceneState?.revealTag(tag) } - .disabled(sceneModel == nil) + .disabled(sceneState == nil) } } diff --git a/core/Sources/BookmarksCore/Commands/SectionCommands.swift b/core/Sources/BookmarksCore/Commands/SectionCommands.swift index 57bc4f38..f7c040e5 100644 --- a/core/Sources/BookmarksCore/Commands/SectionCommands.swift +++ b/core/Sources/BookmarksCore/Commands/SectionCommands.swift @@ -22,7 +22,7 @@ import SwiftUI public struct SectionCommands: Commands { - @FocusedObject var sceneModel: SceneModel? + @FocusedBinding(\.sceneState) var sceneState: SceneState? static func keyEquivalent(_ value: Int) -> KeyEquivalent { return KeyEquivalent(String(value).first!) @@ -36,10 +36,10 @@ public struct SectionCommands: Commands { CommandMenu("Go") { ForEach(Array(BookmarksSection.defaultSections.enumerated()), id: \.element.id) { index, section in Button(section.navigationTitle) { - sceneModel?.section = section + sceneState?.section = section } .keyboardShortcut(Self.keyEquivalent(index + 1), modifiers: .command) - .disabled(sceneModel == nil) + .disabled(sceneState == nil) } } } diff --git a/core/Sources/BookmarksCore/Common/BookmarksSection.swift b/core/Sources/BookmarksCore/Common/BookmarksSection.swift index d479d527..a14cb7ac 100644 --- a/core/Sources/BookmarksCore/Common/BookmarksSection.swift +++ b/core/Sources/BookmarksCore/Common/BookmarksSection.swift @@ -26,7 +26,7 @@ public protocol Sectionable { } -public enum BookmarksSection: Equatable { +public enum BookmarksSection: Equatable, Codable { public static let defaultSections: [Self] = [ .all, diff --git a/core/Sources/BookmarksCore/Common/Settings.swift b/core/Sources/BookmarksCore/Common/Settings.swift index e4290f88..92b24eac 100644 --- a/core/Sources/BookmarksCore/Common/Settings.swift +++ b/core/Sources/BookmarksCore/Common/Settings.swift @@ -38,6 +38,14 @@ final public class Settings: ObservableObject { } } + var browser: BrowserPreference { + if useInAppBrowser { + return .app + } else { + return .system + } + } + @Published public var maximumConcurrentThumbnailDownloads: Int { didSet { defaults.set(maximumConcurrentThumbnailDownloads, forKey: .maximumConcurrentThumbnailDownloads) diff --git a/core/Sources/BookmarksCore/Model/BrowserPreferene.swift b/core/Sources/BookmarksCore/Model/BrowserPreferene.swift index 82352adf..44b340f0 100644 --- a/core/Sources/BookmarksCore/Model/BrowserPreferene.swift +++ b/core/Sources/BookmarksCore/Model/BrowserPreferene.swift @@ -23,5 +23,4 @@ import Foundation enum BrowserPreference { case app case system - case user } diff --git a/core/Sources/BookmarksCore/Model/SceneModel.swift b/core/Sources/BookmarksCore/Model/SceneState.swift similarity index 54% rename from core/Sources/BookmarksCore/Model/SceneModel.swift rename to core/Sources/BookmarksCore/Model/SceneState.swift index 4c1e510a..cbb68702 100644 --- a/core/Sources/BookmarksCore/Model/SceneModel.swift +++ b/core/Sources/BookmarksCore/Model/SceneState.swift @@ -18,14 +18,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import Combine import SwiftUI import Interact -public class SceneModel: ObservableObject { +struct SceneState: Codable, RawRepresentable { - public enum SheetType: Identifiable { + public enum SheetType: Identifiable, Codable { public var id: String { switch self { @@ -43,51 +42,79 @@ public class SceneModel: ObservableObject { case edit(Bookmark.ID) } - var settings: Settings + enum CodingKeys: String, CodingKey { + case section + case sheet + case previewURL + } + + var section: BookmarksSection? = .all + var sheet: SheetType? = nil + var previewURL: URL? = nil + + init() { + + } - @Published public var section: BookmarksSection? = .all - @Published public var sheet: SheetType? = nil - @Published public var previewURL: URL? = nil + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + section = try container.decodeIfPresent(BookmarksSection.self, forKey: .section) + sheet = try container.decodeIfPresent(SheetType.self, forKey: .sheet) + previewURL = try container.decodeIfPresent(URL.self, forKey: .previewURL) + } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(section, forKey: .section) + try container.encodeIfPresent(sheet, forKey: .sheet) + try container.encodeIfPresent(previewURL, forKey: .previewURL) + } + + init?(rawValue: String) { + guard let data = rawValue.data(using: .utf8), + let result = try? JSONDecoder().decode(Self.self, from: data) + else { + return nil + } + self = result + } - public init(settings: Settings) { - self.settings = settings + var rawValue: String { + guard let data = try? JSONEncoder().encode(self), + let string = String(data: data, encoding: .utf8) + else { + return "{}" + } + return string } - @MainActor public func showTags() { + mutating func showTags() { sheet = .tags } - @MainActor public func showSettings() { + mutating func showSettings() { sheet = .settings } - @MainActor public func edit(_ bookmark: Bookmark) { + mutating func edit(_ bookmark: Bookmark) { sheet = .edit(bookmark.id) } - @MainActor func showURL(_ url: URL, browser: BrowserPreference = .user) { - let useInAppBrowser: Bool + mutating func showURL(_ url: URL, browser: BrowserPreference) { switch browser { case .app: - useInAppBrowser = true - case .system: - useInAppBrowser = false - case .user: - useInAppBrowser = settings.useInAppBrowser - } - if useInAppBrowser { previewURL = url - } else { + case .system: Application.open(url) } } - @MainActor public func revealTag(_ tag: String) { + mutating func revealTag(_ tag: String) { sheet = nil section = .tag(tag) } - @MainActor public func handleURL(_ url: URL) { + mutating func handleURL(_ url: URL) { guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return } @@ -108,3 +135,16 @@ public class SceneModel: ObservableObject { } } + +struct FocusedSceneStateValueKey: FocusedValueKey { + typealias Value = Binding +} + +extension FocusedValues { + + var sceneState: FocusedSceneStateValueKey.Value? { + get { self[FocusedSceneStateValueKey.self] } + set { self[FocusedSceneStateValueKey.self] = newValue } + } + +} diff --git a/core/Sources/BookmarksCore/Model/SectionViewModel.swift b/core/Sources/BookmarksCore/Model/SectionViewModel.swift index b30ad303..62527701 100644 --- a/core/Sources/BookmarksCore/Model/SectionViewModel.swift +++ b/core/Sources/BookmarksCore/Model/SectionViewModel.swift @@ -50,7 +50,7 @@ public class SectionViewModel: ObservableObject, Runnable { @Published private var bookmarksLookup: [Bookmark.ID: Bookmark] = [:] private let applicationModel: ApplicationModel? - private let sceneModel: SceneModel? + @Binding private var sceneState: SceneState private let section: BookmarksSection private let openWindow: OpenWindowAction? private var cancellables: Set = [] @@ -59,12 +59,12 @@ public class SectionViewModel: ObservableObject, Runnable { return applicationModel == nil } - public init(applicationModel: ApplicationModel? = nil, - sceneModel: SceneModel? = nil, - section: BookmarksSection = .all, - openWindow: OpenWindowAction? = nil) { + init(applicationModel: ApplicationModel? = nil, + sceneState: Binding = Binding.constant(SceneState()), // TODO: This is ugly. + section: BookmarksSection = .all, + openWindow: OpenWindowAction? = nil) { self.applicationModel = applicationModel - self.sceneModel = sceneModel + _sceneState = sceneState self.section = section self.openWindow = openWindow self.query = section.query @@ -228,7 +228,7 @@ public class SectionViewModel: ObservableObject, Runnable { @MainActor public func getInfo(_ scope: SelectionScope) { for bookmark in bookmarks(scope) { #if os(iOS) - sceneModel?.edit(bookmark) + sceneState.edit(bookmark) #else openWindow?(value: bookmark.id) #endif @@ -237,12 +237,12 @@ public class SectionViewModel: ObservableObject, Runnable { @MainActor func open(_ scope: SelectionScope, location: Bookmark.Location = .web, - browser: BrowserPreference = .user) { + browser: BrowserPreference) { for bookmark in bookmarks(scope) { guard let url = try? bookmark.url(location) else { continue } - sceneModel?.showURL(url, browser: browser) + sceneState.showURL(url, browser: browser) } } @@ -348,7 +348,7 @@ public class SectionViewModel: ObservableObject, Runnable { Divider() #endif MenuItem(LocalizedString("BOOKMARK_MENU_TITLE_VIEW_ON_INTERNET_ARCHIVE"), systemImage: "clock") { - self.open(.items(selection), location: .internetArchive) + self.open(.items(selection), location: .internetArchive, browser: self.applicationModel?.settings.browser ?? .system) } Divider() MenuItem(containsUnreadBookmark ? "Mark as Read" : "Mark as Unread", diff --git a/core/Sources/BookmarksCore/Modifiers/SceneActionHandler.swift b/core/Sources/BookmarksCore/Modifiers/SceneActionHandler.swift index 49d8a98c..5d8c82f9 100644 --- a/core/Sources/BookmarksCore/Modifiers/SceneActionHandler.swift +++ b/core/Sources/BookmarksCore/Modifiers/SceneActionHandler.swift @@ -22,13 +22,13 @@ import SwiftUI struct SceneActionHandler: ViewModifier { - @EnvironmentObject var sceneModel: SceneModel + @Binding var sceneState: SceneState func body(content: Content) -> some View { content .handlesExternalEvents(preferring: ["/open"], allowing: []) .onOpenURL { url in - sceneModel.handleURL(url) + sceneState.handleURL(url) } } @@ -36,8 +36,8 @@ struct SceneActionHandler: ViewModifier { extension View { - public func handlesSceneActions() -> some View { - return modifier(SceneActionHandler()) + func handlesSceneActions(_ sceneState: Binding) -> some View { + return modifier(SceneActionHandler(sceneState: sceneState)) } } diff --git a/core/Sources/BookmarksCore/Toolbars/SelectionToolbar.swift b/core/Sources/BookmarksCore/Toolbars/SelectionToolbar.swift index 42b45446..c0620f5d 100644 --- a/core/Sources/BookmarksCore/Toolbars/SelectionToolbar.swift +++ b/core/Sources/BookmarksCore/Toolbars/SelectionToolbar.swift @@ -24,6 +24,8 @@ public struct SelectionToolbar: CustomizableToolbarContent { struct Content: CustomizableToolbarContent { + @EnvironmentObject var settings: Settings + @ObservedObject var sectionViewModel: SectionViewModel var body: some CustomizableToolbarContent { @@ -41,7 +43,7 @@ public struct SelectionToolbar: CustomizableToolbarContent { ToolbarItem(id: "open") { Button { - sectionViewModel.open(.selection) + sectionViewModel.open(.selection, browser: settings.browser) } label: { Label("Open", systemImage: "safari") } diff --git a/core/Sources/BookmarksCore/Views/ContentView.swift b/core/Sources/BookmarksCore/Views/ContentView.swift index ebf912bc..f19f5a1b 100644 --- a/core/Sources/BookmarksCore/Views/ContentView.swift +++ b/core/Sources/BookmarksCore/Views/ContentView.swift @@ -28,25 +28,24 @@ public struct ContentView: View { @ObservedObject var applicationModel: ApplicationModel - @StateObject var sceneModel: SceneModel + @MainActor @SceneStorage("sceneState") var sceneState = SceneState() + @State var sheet: ApplicationState? = nil public init(applicationModel: ApplicationModel) { self.applicationModel = applicationModel - _sceneModel = StateObject(wrappedValue: SceneModel(settings: applicationModel.settings)) } public var body: some View { NavigationSplitView { - Sidebar() + Sidebar(sceneState: $sceneState) } detail: { - if let section = sceneModel.section { + if let section = sceneState.section { SectionView(applicationModel: applicationModel, - sceneModel: sceneModel, + sceneState: $sceneState, section: section, openWindow: openWindow) .id(section) - .environmentObject(sceneModel) } else { PlaceholderView("Nothing Selected") .searchable() @@ -67,7 +66,7 @@ public struct ContentView: View { } } #if os(iOS) - .sheet(item: $sceneModel.sheet) { sheet in + .sheet(item: $sceneState.sheet) { sheet in switch sheet { case .tags: PhoneTagsView() @@ -77,7 +76,7 @@ public struct ContentView: View { PhoneInfoView(id: id) } } - .fullScreenCover(item: $sceneModel.previewURL) { url in + .fullScreenCover(item: $sceneState.previewURL) { url in PhoneSafariView(url: url) .edgesIgnoringSafeArea(.all) } @@ -90,9 +89,8 @@ public struct ContentView: View { sheet = .logIn } } - .handlesSceneActions() - .environmentObject(sceneModel) - .focusedSceneObject(sceneModel) + .handlesSceneActions($sceneState) + .focusedSceneValue(\.sceneState, $sceneState) } } diff --git a/core/Sources/BookmarksCore/Views/MacSectionGridView.swift b/core/Sources/BookmarksCore/Views/MacSectionGridView.swift index f386d3e1..5e0f35ee 100644 --- a/core/Sources/BookmarksCore/Views/MacSectionGridView.swift +++ b/core/Sources/BookmarksCore/Views/MacSectionGridView.swift @@ -28,6 +28,7 @@ import SelectableCollectionView public struct MacSectionGridView: View { @EnvironmentObject var applicationModel: ApplicationModel + @EnvironmentObject var settings: Settings @EnvironmentObject var sectionViewModel: SectionViewModel let layout = ColumnLayout(spacing: 6.0, @@ -51,7 +52,7 @@ public struct MacSectionGridView: View { } contextMenu: { selection in sectionViewModel.contextMenu(selection) } primaryAction: { selection in - sectionViewModel.open(.items(selection)) + sectionViewModel.open(.items(selection), browser: settings.browser) } keyDown: { event in if event.keyCode == kVK_Space { sectionViewModel.showPreview() diff --git a/core/Sources/BookmarksCore/Views/PhoneSectionGridView.swift b/core/Sources/BookmarksCore/Views/PhoneSectionGridView.swift index 1ef499b7..6144fbbb 100644 --- a/core/Sources/BookmarksCore/Views/PhoneSectionGridView.swift +++ b/core/Sources/BookmarksCore/Views/PhoneSectionGridView.swift @@ -25,6 +25,7 @@ import SwiftUI struct PhoneSectionGridView: View { @EnvironmentObject var applicationModel: ApplicationModel + @EnvironmentObject var settings: Settings @EnvironmentObject var sectionViewModel: SectionViewModel var body: some View { @@ -34,7 +35,7 @@ struct PhoneSectionGridView: View { BookmarkCell(applicationModel: applicationModel, bookmark: bookmark) .aspectRatio(8/9, contentMode: .fit) .onTapGesture { - sectionViewModel.open(.items([bookmark.id])) + sectionViewModel.open(.items([bookmark.id]), browser: settings.browser) } .contextMenu { sectionViewModel.contextMenu([bookmark.id]) diff --git a/core/Sources/BookmarksCore/Views/SectionTableView.swift b/core/Sources/BookmarksCore/Views/SectionTableView.swift index 54a87bd6..e8c9207e 100644 --- a/core/Sources/BookmarksCore/Views/SectionTableView.swift +++ b/core/Sources/BookmarksCore/Views/SectionTableView.swift @@ -33,6 +33,7 @@ struct SectionTableView: View { private let isCompact = false #endif + @EnvironmentObject var settings: Settings @EnvironmentObject var sectionViewModel: SectionViewModel var body: some View { @@ -77,7 +78,7 @@ struct SectionTableView: View { .contextMenu(forSelectionType: Bookmark.ID.self) { selection in sectionViewModel.contextMenu(selection) } primaryAction: { selection in - sectionViewModel.open(.items(selection)) + sectionViewModel.open(.items(selection), browser: settings.browser) } .listStyle(.plain) } else { @@ -103,7 +104,7 @@ struct SectionTableView: View { .contextMenu(forSelectionType: Bookmark.ID.self) { selection in sectionViewModel.contextMenu(selection) } primaryAction: { selection in - sectionViewModel.open(.items(selection)) + sectionViewModel.open(.items(selection), browser: settings.browser) } } } diff --git a/core/Sources/BookmarksCore/Views/SectionView.swift b/core/Sources/BookmarksCore/Views/SectionView.swift index b225a8e8..54d99bf5 100644 --- a/core/Sources/BookmarksCore/Views/SectionView.swift +++ b/core/Sources/BookmarksCore/Views/SectionView.swift @@ -29,13 +29,13 @@ public struct SectionView: View { @StateObject var sectionViewModel: SectionViewModel - public init(applicationModel: ApplicationModel, - sceneModel: SceneModel, + init(applicationModel: ApplicationModel, + sceneState: Binding, section: BookmarksSection, openWindow: OpenWindowAction) { self.applicationModel = applicationModel _sectionViewModel = StateObject(wrappedValue: SectionViewModel(applicationModel: applicationModel, - sceneModel: sceneModel, + sceneState: sceneState, section: section, openWindow: openWindow)) } diff --git a/core/Sources/BookmarksCore/Views/Sidebar.swift b/core/Sources/BookmarksCore/Views/Sidebar.swift index 098b9d49..12dc4de9 100644 --- a/core/Sources/BookmarksCore/Views/Sidebar.swift +++ b/core/Sources/BookmarksCore/Views/Sidebar.swift @@ -25,27 +25,23 @@ public struct Sidebar: View { @EnvironmentObject var applicationModel: ApplicationModel @EnvironmentObject var settings: Settings - @FocusedObject var sceneModel: SceneModel? - - public init() { - - } + @Binding var sceneState: SceneState public var body: some View { - SidebarContentView() + SidebarContentView(sceneState: $sceneState) #if os(iOS) .navigationTitle("Bookmarks") .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button { - sceneModel?.showSettings() + sceneState.showSettings() } label: { Image(systemName: "gear") } } ToolbarItem(placement: .navigationBarTrailing) { Button { - sceneModel?.showTags() + sceneState.showTags() } label: { Image(systemName: "tag") } diff --git a/core/Sources/BookmarksCore/Views/SidebarContentView.swift b/core/Sources/BookmarksCore/Views/SidebarContentView.swift index 4ebdba7f..1e6800b8 100644 --- a/core/Sources/BookmarksCore/Views/SidebarContentView.swift +++ b/core/Sources/BookmarksCore/Views/SidebarContentView.swift @@ -24,16 +24,13 @@ import SwiftUI public struct SidebarContentView: View { @EnvironmentObject var applicationModel: ApplicationModel - @EnvironmentObject var sceneModel: SceneModel @EnvironmentObject var settings: Settings - public init() { - - } + @Binding var sceneState: SceneState public var body: some View { - List(selection: $sceneModel.section) { - if case let .tag(tag) = sceneModel.section, + List(selection: $sceneState.section) { + if case let .tag(tag) = sceneState .section, !settings.favoriteTags.contains(tag), !applicationModel.topTags.contains(tag) { Section("Search") { diff --git a/ios/Bookmarks/BookmarksApp.swift b/ios/Bookmarks/BookmarksApp.swift index 9dd5d99f..ee5f1521 100644 --- a/ios/Bookmarks/BookmarksApp.swift +++ b/ios/Bookmarks/BookmarksApp.swift @@ -27,7 +27,6 @@ struct BookmarksApp: App { @Environment(\.scenePhase) private var phase - @FocusedObject var sceneModel: SceneModel? @FocusedObject var sectionViewModel: SectionViewModel? var applicationModel: ApplicationModel diff --git a/macos/Bookmarks/BookmarksApp.swift b/macos/Bookmarks/BookmarksApp.swift index 178c7049..11306710 100644 --- a/macos/Bookmarks/BookmarksApp.swift +++ b/macos/Bookmarks/BookmarksApp.swift @@ -29,7 +29,6 @@ import BookmarksCore @main struct BookmarksApp: App { - @FocusedObject var sceneModel: SceneModel? @FocusedObject var sectionViewModel: SectionViewModel? var applicationModel: ApplicationModel