Skip to content

Commit

Permalink
Drop bookmarks storyboard (#2148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Feb 5, 2024
1 parent b0f30b5 commit 2e4e1a3
Show file tree
Hide file tree
Showing 30 changed files with 1,046 additions and 1,230 deletions.
52 changes: 10 additions & 42 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

69 changes: 0 additions & 69 deletions DuckDuckGo/Bookmarks/Extensions/NSPopUpButtonExtension.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ import Foundation

final class BookmarkListTreeControllerDataSource: BookmarkTreeControllerDataSource {

private let bookmarkManager: BookmarkManager

init(bookmarkManager: BookmarkManager) {
self.bookmarkManager = bookmarkManager
}

func treeController(treeController: BookmarkTreeController, childNodesFor node: BookmarkNode) -> [BookmarkNode] {
return node.isRoot ? childNodesForRootNode(node) : childNodes(node)
}

// MARK: - Private

private func childNodesForRootNode(_ node: BookmarkNode) -> [BookmarkNode] {
let topLevelNodes = LocalBookmarkManager.shared.list?.topLevelEntities.compactMap { (item) -> BookmarkNode? in
let topLevelNodes = bookmarkManager.list?.topLevelEntities.compactMap { (item) -> BookmarkNode? in
if let folder = item as? BookmarkFolder {
let itemNode = node.createChildNode(item)
itemNode.canHaveChildNodes = !folder.children.isEmpty
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/Bookmarks/Model/BookmarkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ protocol BookmarkManager: AnyObject {
var listPublisher: Published<BookmarkList?>.Publisher { get }
var list: BookmarkList? { get }

func requestSync()

}

final class LocalBookmarkManager: BookmarkManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS

init(
contentMode: ContentMode,
bookmarkManager: BookmarkManager = LocalBookmarkManager.shared,
bookmarkManager: BookmarkManager,
treeController: BookmarkTreeController,
presentFaviconsFetcherOnboarding: (() -> Void)? = nil
) {
Expand Down Expand Up @@ -117,11 +117,12 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS
}

func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
guard let node = item as? BookmarkNode,
let cell = outlineView.makeView(withIdentifier: BookmarkOutlineViewCell.identifier, owner: self) as? BookmarkOutlineViewCell else {
assertionFailure("\(#file): Failed to create BookmarkOutlineViewCell or cast item to Node")
guard let node = item as? BookmarkNode else {
assertionFailure("\(#file): Failed to cast item to Node")
return nil
}
let cell = outlineView.makeView(withIdentifier: .init(BookmarkOutlineCellView.className()), owner: self) as? BookmarkOutlineCellView
?? BookmarkOutlineCellView(identifier: .init(BookmarkOutlineCellView.className()))

if let bookmark = node.representedObject as? Bookmark {
cell.update(from: bookmark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class BookmarkSidebarTreeController: BookmarkTreeControllerDataSource {

private let bookmarkManager: BookmarkManager

init(bookmarkManager: BookmarkManager = LocalBookmarkManager.shared) {
init(bookmarkManager: BookmarkManager) {
self.bookmarkManager = bookmarkManager
}

Expand Down
7 changes: 4 additions & 3 deletions DuckDuckGo/Bookmarks/Model/PseudoFolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
// limitations under the License.
//

import AppKit
import Foundation

final class PseudoFolder: Equatable {

static let favorites = PseudoFolder(id: UUID().uuidString, name: UserText.favorites, icon: NSImage(named: "FavoriteFilledBorder")!)
static let bookmarks = PseudoFolder(id: UUID().uuidString, name: UserText.bookmarks, icon: NSImage(named: "Folder")!)
static let favorites = PseudoFolder(id: UUID().uuidString, name: UserText.favorites, icon: .favoriteFilledBorder)
static let bookmarks = PseudoFolder(id: UUID().uuidString, name: UserText.bookmarks, icon: .folder)

let id: String
let name: String
Expand All @@ -38,7 +39,7 @@ final class PseudoFolder: Equatable {
}

static func == (lhs: PseudoFolder, rhs: PseudoFolder) -> Bool {
return lhs.name == rhs.name
return lhs.id == rhs.id
}

}
Loading

0 comments on commit 2e4e1a3

Please sign in to comment.