Skip to content

Commit

Permalink
Merge branch 'release/0.30.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Nov 18, 2022
2 parents 0217b54 + a21e240 commit aa1cff6
Show file tree
Hide file tree
Showing 60 changed files with 1,466 additions and 927 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: PR Checks

on:
push:
branches: [ develop ]
branches: [ develop, "release/**" ]
pull_request:
branches: [ develop ]
branches: [ develop, "release/**" ]


jobs:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

steps:
- name: Register SSH keys for submodules access
uses: webfactory/ssh-agent@v0.5.4
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: |
${{ secrets.SSH_PRIVATE_KEY_FIND_IN_PAGE }}
Expand All @@ -69,8 +69,8 @@ jobs:
with:
submodules: recursive

- name: Select Xcode 14.0
run: sudo xcode-select -s /Applications/Xcode_14.0.app/Contents/Developer
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer

- name: Build and test
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
if: github.event.inputs.asana-task-url
run: echo "asana_task_url_arg=-a ${{ github.event.inputs.asana-task-url }}" >> $GITHUB_ENV

- name: Select Xcode 13.4
run: sudo xcode-select -s /Applications/Xcode_13.4.app/Contents/Developer
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_14.1.app/Contents/Developer

- name: Archive and notarize the app
env:
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MARKETING_VERSION = 0.30.7
MARKETING_VERSION = 0.30.8

38 changes: 16 additions & 22 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "AutoconsentMessageProtocolTests/testInitResponds()">
</Test>
<Test
Identifier = "CBRCompileTimeReporterTests">
</Test>
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import WebKit
import os
import BrowserServicesKit
import UserScript

protocol AutoconsentUserScriptDelegate: AnyObject {
func autoconsentUserScript(consentStatus: CookieConsentInfo)
Expand Down
22 changes: 20 additions & 2 deletions DuckDuckGo/Bookmarks/Model/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ internal class BaseBookmarkEntity {
return request
}

static func favorite(with uuid: UUID) -> NSFetchRequest<BookmarkManagedObject> {
let request = NSFetchRequest<BookmarkManagedObject>(entityName: "BookmarkManagedObject")
request.predicate = NSPredicate(format: "id == %@ AND %K != nil AND %K == NO",
uuid as CVarArg,
#keyPath(BookmarkManagedObject.favoritesFolder),
#keyPath(BookmarkManagedObject.isFolder))
return request
}

static func entities(with identifiers: [UUID]) -> NSFetchRequest<BookmarkManagedObject> {
let request = NSFetchRequest<BookmarkManagedObject>(entityName: "BookmarkManagedObject")
request.predicate = NSPredicate(format: "id IN %@", identifiers)
Expand All @@ -34,7 +43,16 @@ internal class BaseBookmarkEntity {

static func topLevelEntitiesFetchRequest() -> NSFetchRequest<BookmarkManagedObject> {
let request = NSFetchRequest<BookmarkManagedObject>(entityName: "BookmarkManagedObject")
request.predicate = NSPredicate(format: "parentFolder == nil")
request.predicate = NSPredicate(format: "id != %@ AND parentFolder == nil", UUID.favoritesFolderUUID as CVarArg)
return request
}

static func favoritesFolderFetchRequest() -> NSFetchRequest<BookmarkManagedObject> {
let request = NSFetchRequest<BookmarkManagedObject>(entityName: "BookmarkManagedObject")
request.predicate = NSPredicate(format: "id == %@ AND %K == nil AND %K == YES",
UUID.favoritesFolderUUID as CVarArg,
#keyPath(BookmarkManagedObject.parentFolder),
#keyPath(BookmarkManagedObject.isFolder))
return request
}

Expand Down Expand Up @@ -81,7 +99,7 @@ internal class BaseBookmarkEntity {
url: url,
title: title,
oldFavicon: managedObject.faviconEncrypted as? NSImage,
isFavorite: managedObject.isFavorite,
isFavorite: managedObject.favoritesFolder != nil,
parentFolderUUID: parentFolderUUID)
}
}
Expand Down
9 changes: 2 additions & 7 deletions DuckDuckGo/Bookmarks/Model/BookmarkList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,17 @@ struct BookmarkList {
return bookmarks
}

init(entities: [BaseBookmarkEntity] = [], topLevelEntities: [BaseBookmarkEntity] = []) {
init(entities: [BaseBookmarkEntity] = [], topLevelEntities: [BaseBookmarkEntity] = [], favorites: [BaseBookmarkEntity] = []) {
let bookmarks = entities.compactMap { $0 as? Bookmark }
let keysOrdered = bookmarks.compactMap { IdentifiableBookmark(from: $0) }
var favoriteKeysOrdered = [IdentifiableBookmark]()

var itemsDict = [URL: [Bookmark]]()

for bookmark in bookmarks {
itemsDict[bookmark.url] = (itemsDict[bookmark.url] ?? []) + [bookmark]

if bookmark.isFavorite {
favoriteKeysOrdered.append(IdentifiableBookmark(from: bookmark))
}
}

self.favoriteBookmarksOrdered = favoriteKeysOrdered
self.favoriteBookmarksOrdered = favorites.compactMap({$0 as? Bookmark}).map(IdentifiableBookmark.init(from:))
self.allBookmarkURLsOrdered = keysOrdered
self.itemsDict = itemsDict
self.topLevelEntities = topLevelEntities
Expand Down
25 changes: 24 additions & 1 deletion DuckDuckGo/Bookmarks/Model/BookmarkManagedObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ extension BookmarkManagedObject {
case folderStructureHasCycle
case folderHasURL
case bookmarkRequiresURL
case invalidFavoritesFolder
}

public var mutableChildren: NSMutableOrderedSet {
return mutableOrderedSetValue(forKey: "children")
}

public var mutableFavorites: NSMutableOrderedSet {
return mutableOrderedSetValue(forKey: "favorites")
}

public override func validateForInsert() throws {
try super.validateForInsert()
try validate()
Expand All @@ -42,17 +47,29 @@ extension BookmarkManagedObject {
try validate()
}

static func createFavoritesFolder(in context: NSManagedObjectContext) -> NSManagedObject {
let managedObject = NSEntityDescription.insertNewObject(forEntityName: BookmarkManagedObject.className(), into: context)

managedObject.setValue(UUID.favoritesFolderUUID, forKey: "id")
managedObject.setValue("Favorites Folder" as NSString, forKey: "titleEncrypted")
managedObject.setValue(true, forKey: "isFolder")
managedObject.setValue(NSDate.now, forKey: "dateAdded")

return managedObject
}

// MARK: - Private

func validate() throws {
try validateThatEntitiesExistInsideTheRootFolder()
try validateBookmarkURLRequirement()
try validateThatFoldersDoNotHaveURLs()
try validateThatFolderHierarchyHasNoCycles()
try validateFavoritesFolder()
}

func validateThatEntitiesExistInsideTheRootFolder() throws {
if parentFolder == nil, id != .rootBookmarkFolderUUID {
if parentFolder == nil, ![UUID.rootBookmarkFolderUUID, .favoritesFolderUUID].contains(id) {
throw BookmarkError.mustExistInsideRootFolder
}
}
Expand All @@ -63,6 +80,12 @@ extension BookmarkManagedObject {
}
}

func validateFavoritesFolder() throws {
if let favoritesFolderID = favoritesFolder?.id, favoritesFolderID != .favoritesFolderUUID {
throw BookmarkError.invalidFavoritesFolder
}
}

func validateThatFoldersDoNotHaveURLs() throws {
if isFolder, urlEncrypted != nil {
throw BookmarkError.folderHasURL
Expand Down
19 changes: 17 additions & 2 deletions DuckDuckGo/Bookmarks/Model/BookmarkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protocol BookmarkManager: AnyObject {
func update(objectsWithUUIDs uuids: [UUID], update: @escaping (BaseBookmarkEntity) -> Void, completion: @escaping (Error?) -> Void)
func canMoveObjectWithUUID(objectUUID uuid: UUID, to parent: BookmarkFolder) -> Bool
func move(objectUUIDs: [UUID], toIndex: Int?, withinParentFolder: ParentFolderType, completion: @escaping (Error?) -> Void)
func moveFavorites(with objectUUIDs: [UUID], toIndex: Int?, completion: @escaping (Error?) -> Void)
func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult

// Wrapper definition in a protocol is not supported yet
Expand Down Expand Up @@ -80,7 +81,14 @@ final class LocalBookmarkManager: BookmarkManager {
return
}

self?.list = BookmarkList(entities: bookmarks, topLevelEntities: topLevelEntities)
self?.bookmarkStore.loadAll(type: .favorites) { [weak self] (favorites, error) in
guard error == nil, let favorites = favorites else {
os_log("LocalBookmarkManager: Failed to fetch favorites.", type: .error)
return
}

self?.list = BookmarkList(entities: bookmarks, topLevelEntities: topLevelEntities, favorites: favorites)
}
}
}
}
Expand Down Expand Up @@ -239,7 +247,14 @@ final class LocalBookmarkManager: BookmarkManager {
completion(error)
}
}


func moveFavorites(with objectUUIDs: [UUID], toIndex index: Int?, completion: @escaping (Error?) -> Void) {
bookmarkStore.moveFavorites(with: objectUUIDs, toIndex: index) { [weak self] error in
self?.loadBookmarks()
completion(error)
}
}

// MARK: - Favicons

private func favicon(for host: String?) -> NSImage? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Bookmark 2.xcdatamodel</string>
<string>Bookmark 3.xcdatamodel</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20D91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21512" systemVersion="22A380" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="BookmarkManagedObject" representedClassName="BookmarkManagedObject" syncable="YES" codeGenerationType="class">
<attribute name="dateAdded" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="faviconEncrypted" optional="YES" attributeType="Transformable" valueTransformerName="NSImageTransformer"/>
<attribute name="id" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="isFavorite" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="isFavorite" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="isFolder" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="titleEncrypted" attributeType="Transformable" valueTransformerName="NSStringTransformer"/>
<attribute name="urlEncrypted" optional="YES" attributeType="Transformable" valueTransformerName="NSURLTransformer"/>
Expand All @@ -22,7 +22,4 @@
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<elements>
<element name="BookmarkManagedObject" positionX="-54" positionY="-54" width="128" height="164"/>
</elements>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21512" systemVersion="22A380" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="BookmarkManagedObject" representedClassName="BookmarkManagedObject" syncable="YES" codeGenerationType="class">
<attribute name="dateAdded" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="faviconEncrypted" optional="YES" attributeType="Transformable" valueTransformerName="NSImageTransformer"/>
<attribute name="id" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="isFavorite" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="isFolder" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="titleEncrypted" attributeType="Transformable" valueTransformerName="NSStringTransformer"/>
<attribute name="urlEncrypted" optional="YES" attributeType="Transformable" valueTransformerName="NSURLTransformer"/>
<relationship name="children" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="BookmarkManagedObject" inverseName="parentFolder" inverseEntity="BookmarkManagedObject"/>
<relationship name="favorites" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="BookmarkManagedObject" inverseName="favoritesFolder" inverseEntity="BookmarkManagedObject"/>
<relationship name="favoritesFolder" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="BookmarkManagedObject" inverseName="favorites" inverseEntity="BookmarkManagedObject"/>
<relationship name="parentFolder" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="BookmarkManagedObject" inverseName="children" inverseEntity="BookmarkManagedObject"/>
<fetchIndex name="byDateAdded">
<fetchIndexElement property="dateAdded" type="Binary" order="descending"/>
</fetchIndex>
<fetchIndex name="byID">
<fetchIndexElement property="id" type="Binary" order="ascending"/>
</fetchIndex>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="id"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
</model>
110 changes: 0 additions & 110 deletions DuckDuckGo/Bookmarks/Services/Bookmark.xcmappingmodel/xcmapping.xml

This file was deleted.

35 changes: 0 additions & 35 deletions DuckDuckGo/Bookmarks/Services/BookmarkMigrationPolicy.swift

This file was deleted.

Loading

0 comments on commit aa1cff6

Please sign in to comment.