Skip to content

Commit

Permalink
Merge branch 'main' into sam/fix-vpn-app-store-agent-compilation
Browse files Browse the repository at this point in the history
# By Alexey Martemyanov (11) and others
# Via Dominik Kapusta (3) and others
* main: (56 commits)
  Adds info about whether the login items are actually running (#2122)
  Remove connection status awaiter. (#2121)
  Launch VPN Location screen from status view  (#2077)
  Display different copy in alerts when a flag is enabled in a newer version (#2114)
  Remove delayed webView attaching to main window (#2116)
  Always start onboarding from the beginning when shown (#2117)
  Update spacing between UI components in settings (#2109)
  Show history menu on cmd+y shortcut (#2112)
  Bump version to 1.72.0 (112)
  Update embedded files
  fix WebView value validation popover crash when WebView not in hierarchy (#2108)
  Fix agent startup (#2107)
  Support brand UA (#2085)
  fix Safari favicons import (#2106)
  Add page attributes to print settings (#2104)
  Bump version to 1.72.0 (111)
  Alex/disable onboarding existing users (#2105)
  Bump version to 1.71.2 (110)
  Fixes a multithreading issue in `NetworkConnectionTester` (BSK) (#2102)
  Avoid sending latency immediately after the monitor starts (#2103)
  ...

# Conflicts:
#	Configuration/BuildNumber.xcconfig
#	DuckDuckGo/VPNFeedbackForm/VPNMetadataCollector.swift
#	UnitTests/VPNFeedbackForm/VPNFeedbackFormViewModelTests.swift
  • Loading branch information
samsymons committed Jan 25, 2024
2 parents 0a10948 + ea2720d commit 9a2e22e
Show file tree
Hide file tree
Showing 160 changed files with 2,104 additions and 986 deletions.
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 105
CURRENT_PROJECT_VERSION = 112
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.71.0
MARKETING_VERSION = 1.72.0
34 changes: 17 additions & 17 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "7f9eb807af196ec3db8fe6f0b168df89ea16a11c",
"version" : "101.1.4"
"revision" : "93fa38a7412fd665ed2f72df0fd26f69e61c9fe1",
"version" : "102.0.1"
}
},
{
Expand Down Expand Up @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "43c802fb7f96e090dde015344a94b5e85779eff1",
"version" : "509.1.0"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
fileStore = EncryptedFileStore()
}

// keep this on top!
// disable onboarding for existing users
let isOnboardingFinished = UserDefaultsWrapper<Bool>(key: .onboardingFinished, defaultValue: false)
if !isOnboardingFinished.wrappedValue,
FileManager.default.fileExists(atPath: URL.sandboxApplicationSupportURL.path) {
isOnboardingFinished.wrappedValue = true
}

let internalUserDeciderStore = InternalUserDeciderStore(fileStore: fileStore)
internalUserDecider = DefaultInternalUserDecider(store: internalUserDeciderStore)

Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/Application/URLEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ final class URLEventHandler {
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
case AppLaunchCommand.shareFeedback.launchURL:
WindowControllersManager.shared.showShareFeedbackModal()
case AppLaunchCommand.showVPNLocations.launchURL:
WindowControllersManager.shared.showPreferencesTab(withSelectedPane: .vpn)
WindowControllersManager.shared.showLocationPickerSheet()
default:
return
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public final class ContentOverlayViewController: NSViewController, EmailManagerR

public override func viewWillDisappear() {
// We should never see this but it's better than a flash of old content
webView.load(URLRequest(url: URL(string: "about:blank")!))
webView.load(URLRequest(url: .blankPage))
}

public func messageMouseMove(x: CGFloat, y: CGFloat) {
Expand Down
15 changes: 0 additions & 15 deletions DuckDuckGo/Bookmarks/Model/BookmarkNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ final class BookmarkNode: Hashable {
return node
}

class func bookmarkNodesSortedAlphabetically(_ nodes: [BookmarkNode]) -> [BookmarkNode] {
return nodes.sorted { (firstNode, secondNode) -> Bool in
guard let firstBookmark = firstNode.representedObject as? BaseBookmarkEntity,
let secondBookmark = secondNode.representedObject as? BaseBookmarkEntity else {
return false
}

return firstBookmark.title.localizedStandardCompare(secondBookmark.title) == .orderedAscending
}
}

weak var parent: BookmarkNode?

let uniqueID: Int
Expand Down Expand Up @@ -232,8 +221,4 @@ extension Array where Element == BookmarkNode {
return self.map { $0.representedObject }
}

func bookmarksSortedAlphabetically() -> [BookmarkNode] {
return BookmarkNode.bookmarkNodesSortedAlphabetically(self)
}

}
51 changes: 31 additions & 20 deletions DuckDuckGo/Bookmarks/Model/BookmarkOutlineViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS
validateDrop info: NSDraggingInfo,
proposedItem item: Any?,
proposedChildIndex index: Int) -> NSDragOperation {
if contentMode == .foldersOnly, index != -1 {
let destinationNode = nodeForItem(item)

if contentMode == .foldersOnly {
// when in folders sidebar mode only allow moving a folder to another folder (or root)
if destinationNode.representedObject is BookmarkFolder
|| (destinationNode.representedObject as? PseudoFolder == .bookmarks) {
return .move
}
return .none
}

let destinationNode = nodeForItem(item)

let bookmarks = PasteboardBookmark.pasteboardBookmarks(with: info.draggingPasteboard)
let folders = PasteboardFolder.pasteboardFolders(with: info.draggingPasteboard)

Expand Down Expand Up @@ -255,7 +260,8 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS

// Handle the nil destination case:

if let pseudoFolder = representedObject as? PseudoFolder {
if contentMode == .bookmarksAndFolders,
let pseudoFolder = representedObject as? PseudoFolder {
if pseudoFolder == .favorites {
bookmarkManager.update(objectsWithUUIDs: draggedObjectIdentifiers, update: { entity in
let bookmark = entity as? Bookmark
Expand All @@ -278,25 +284,30 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS

// Handle the existing destination case:

if let parent = representedObject as? BookmarkFolder {
bookmarkManager.move(objectUUIDs: draggedObjectIdentifiers, toIndex: index, withinParentFolder: .parent(uuid: parent.id)) { error in
if let error = error {
os_log("Failed to accept existing parent drop via outline view: %s", error.localizedDescription)
}
}
var index = index
// for folders-only calculate new real index based on the nearest folder index
if contentMode == .foldersOnly,
index > -1,
// get folder before the insertion point (or the first one)
let nearestObject = (outlineView.child(max(0, index - 1), ofItem: item) as? BookmarkNode)?.representedObject as? BookmarkFolder,
// get all the children of a new parent folder
let siblings = (representedObject as? BookmarkFolder)?.children ?? bookmarkManager.list?.topLevelEntities {

// insert after the nearest item (or in place of the nearest item for index == 0)
index = (siblings.firstIndex(of: nearestObject) ?? 0) + (index == 0 ? 0 : 1)
} else if index == -1 {
// drop onto folder
index = 0
}

return true
} else if representedObject == nil {
bookmarkManager.move(objectUUIDs: draggedObjectIdentifiers, toIndex: index, withinParentFolder: .root) { error in
if let error = error {
os_log("Failed to accept existing parent drop via outline view: %s", error.localizedDescription)
}
let parent: ParentFolderType = (representedObject as? BookmarkFolder).map { .parent(uuid: $0.id) } ?? .root
bookmarkManager.move(objectUUIDs: draggedObjectIdentifiers, toIndex: index, withinParentFolder: parent) { error in
if let error = error {
os_log("Failed to accept existing parent drop via outline view: %s", error.localizedDescription)
}

return true
} else {
return false
}

return true
}

func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ final class BookmarkSidebarTreeController: BookmarkTreeControllerDataSource {
return folderNode
} ?? []

return nodes.bookmarksSortedAlphabetically()
return nodes
}

private func childNodes(for folder: BookmarkFolder, parentNode: BookmarkNode) -> [BookmarkNode] {
Expand All @@ -100,7 +100,7 @@ final class BookmarkSidebarTreeController: BookmarkTreeControllerDataSource {
updatedChildNodes += [newNode]
}

return updatedChildNodes.bookmarksSortedAlphabetically()
return updatedChildNodes
}

}
18 changes: 14 additions & 4 deletions DuckDuckGo/Bookmarks/Services/LocalBookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ final class LocalBookmarkStore: BookmarkStore {
context: context)
}

if let bookmarksBar = bookmarks.topLevelFolders.bookmarkBar.children {
if let bookmarksBar = bookmarks.topLevelFolders.bookmarkBar?.children {
let result = recursivelyCreateEntities(from: bookmarksBar,
parent: parent,
markBookmarksAsFavorite: makeFavorties,
Expand All @@ -775,9 +775,19 @@ final class LocalBookmarkStore: BookmarkStore {
total += result
}

if let otherBookmarks = bookmarks.topLevelFolders.otherBookmarks.children {
let result = recursivelyCreateEntities(from: otherBookmarks,
parent: parent,
for folder in [bookmarks.topLevelFolders.otherBookmarks, bookmarks.topLevelFolders.syncedBookmarks] {
guard let folder, let children = folder.children else { continue }

var folderParent = parent
// keep the original imported folder if bookmarks bar is not empty
// import to import root otherwise
if !parent.childrenArray.isEmpty, !folder.name.isEmpty, !children.isEmpty {
folderParent = BookmarkEntity.makeFolder(title: folder.name,
parent: parent,
context: context)
}
let result = recursivelyCreateEntities(from: children,
parent: folderParent,
markBookmarksAsFavorite: false,
in: context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ final class BookmarkManagementDetailViewController: NSViewController, NSMenuItem
override func viewDidLoad() {
super.viewDidLoad()

let nib = NSNib(nibNamed: "BookmarkTableCellView", bundle: Bundle.main)
tableView.register(nib, forIdentifier: Constants.bookmarkCellIdentifier)
tableView.setDraggingSourceOperationMask([.move], forLocal: true)
tableView.registerForDraggedTypes([BookmarkPasteboardWriter.bookmarkUTIInternalType,
FolderPasteboardWriter.folderUTIInternalType])
Expand Down Expand Up @@ -189,9 +187,9 @@ final class BookmarkManagementDetailViewController: NSViewController, NSMenuItem

private func endEditing() {
if let editingIndex = editingBookmarkIndex?.index {
self.editingBookmarkIndex = nil
animateEditingState(forRowAt: editingIndex, editing: false)
}
self.editingBookmarkIndex = nil
}

private func updateEditingState(forRowAt index: Int) {
Expand Down Expand Up @@ -289,27 +287,27 @@ extension BookmarkManagementDetailViewController: NSTableViewDelegate, NSTableVi
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
guard let entity = fetchEntity(at: row) else { return nil }

if let cell = tableView.makeView(withIdentifier: Constants.bookmarkCellIdentifier, owner: nil) as? BookmarkTableCellView {
cell.delegate = self
let cell = tableView.makeView(withIdentifier: Constants.bookmarkCellIdentifier, owner: nil) as? BookmarkTableCellView
?? BookmarkTableCellView(identifier: Constants.bookmarkCellIdentifier)

if let bookmark = entity as? Bookmark {
cell.update(from: bookmark)
cell.editing = bookmark.id == editingBookmarkIndex?.uuid
cell.delegate = self

if bookmark.favicon(.small) == nil {
faviconsFetcherOnboarding?.presentOnboardingIfNeeded()
}
} else if let folder = entity as? BookmarkFolder {
cell.update(from: folder)
cell.editing = folder.id == editingBookmarkIndex?.uuid
} else {
assertionFailure("Failed to cast bookmark")
if let bookmark = entity as? Bookmark {
cell.update(from: bookmark)
cell.editing = bookmark.id == editingBookmarkIndex?.uuid

if bookmark.favicon(.small) == nil {
faviconsFetcherOnboarding?.presentOnboardingIfNeeded()
}
cell.isSelected = tableView.selectedRowIndexes.contains(row)
return cell
} else if let folder = entity as? BookmarkFolder {
cell.update(from: folder)
cell.editing = folder.id == editingBookmarkIndex?.uuid
} else {
assertionFailure("Failed to cast bookmark")
}
cell.isSelected = tableView.selectedRowIndexes.contains(row)

return nil
return cell
}

func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
Expand Down Expand Up @@ -504,16 +502,20 @@ extension BookmarkManagementDetailViewController: BookmarkTableCellViewDelegate

func bookmarkTableCellView(_ cell: BookmarkTableCellView, updatedBookmarkWithUUID uuid: String, newTitle: String, newUrl: String) {
let row = tableView.row(for: cell)

guard let bookmark = fetchEntity(at: row) as? Bookmark, bookmark.id == editingBookmarkIndex?.uuid else {
defer {
endEditing()
}
guard var bookmark = fetchEntity(at: row) as? Bookmark, bookmark.id == uuid else {
return
}

bookmark.title = newTitle.isEmpty ? bookmark.title : newTitle
bookmarkManager.update(bookmark: bookmark)

if let newURL = newUrl.url, newURL.absoluteString != bookmark.url {
_ = bookmarkManager.updateUrl(of: bookmark, to: newURL)
if let url = newUrl.url, url.absoluteString != bookmark.url {
bookmark = bookmarkManager.updateUrl(of: bookmark, to: url) ?? bookmark
}
let bookmarkTitle = newTitle.isEmpty ? bookmark.title : newTitle
if bookmark.title != bookmarkTitle {
bookmark.title = bookmarkTitle
bookmarkManager.update(bookmark: bookmark)
}
}

Expand Down
Loading

0 comments on commit 9a2e22e

Please sign in to comment.