Skip to content

Commit

Permalink
Merge branch 'release/0.28.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Aug 26, 2022
2 parents d1b95e0 + 6895447 commit e36ef59
Show file tree
Hide file tree
Showing 55 changed files with 282 additions and 478 deletions.
26 changes: 13 additions & 13 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5268,7 +5268,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "REVIEW=1";
Expand All @@ -5277,7 +5277,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.review;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Review";
Expand Down Expand Up @@ -5419,15 +5419,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -5619,15 +5619,15 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -5872,15 +5872,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand All @@ -5901,15 +5901,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -6034,7 +6034,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.28.5;
CURRENT_PROJECT_VERSION = 0.28.6;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "REVIEW=1";
Expand All @@ -6043,7 +6043,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.28.5;
MARKETING_VERSION = 0.28.6;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.review;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Review";
Expand Down Expand Up @@ -6212,7 +6212,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 24.0.0;
version = 27.0.1;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/API/APIRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum APIRequest {
var etag = httpResponse?.headerValue(for: APIHeaders.Name.etag)

// Handle weak etags
etag = etag?.drop(prefix: "W/")
etag = etag?.dropping(prefix: "W/")
completion(Response(data: data, etag: etag, urlResponse: response), nil)
}
}
Expand All @@ -105,7 +105,7 @@ enum APIRequest {
headers: HTTPHeaders = APIHeaders().defaultHeaders,
timeoutInterval: TimeInterval = 60.0) -> URLRequest {
let url = (try? parameters?.reduce(url) { partialResult, parameter in
try partialResult.addParameter(
try partialResult.appendingParameter(
name: parameter.key,
value: parameter.value,
allowedReservedCharacters: allowedQueryReservedCharacters
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/App Delegate/CopyHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class CopyHandler: NSObject {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(selectedText, forType: .string)

if let urlString = URL(trimmedAddressBarString: selectedText.trimmingWhitespaces())?.absoluteString,
if let urlString = URL(trimmedAddressBarString: selectedText.trimmingWhitespace())?.absoluteString,
urlString == selectedText {
NSPasteboard.general.setString(urlString, forType: .URL)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,10 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.600",
"blue" : "0xEF",
"green" : "0x69",
"red" : "0x39"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "contrast",
"value" : "high"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.600",
"blue" : "0.937",
"green" : "0.412",
"red" : "0.224"
"alpha" : "1.000",
"blue" : "0xFC",
"green" : "0x7A",
"red" : "0x3A"
}
},
"idiom" : "universal"
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/Autoconsent/UI/CookieConsentPopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class CookieConsentPopover {
viewController.delegate = self
}

public func close(animated: Bool) {
public func close(animated: Bool, completion: (() -> Void)? = nil) {
guard let overlayWindow = windowController.window else {
return
}
Expand All @@ -57,6 +57,7 @@ public final class CookieConsentPopover {
let removeWindow = {
overlayWindow.parent?.removeChildWindow(overlayWindow)
overlayWindow.orderOut(nil)
completion?()
}

if animated {
Expand Down
48 changes: 39 additions & 9 deletions DuckDuckGo/Autoconsent/UI/CookieConsentPopoverManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,51 @@ final class CookieConsentPopoverManager: CookieConsentPopoverDelegate {
var completion: ((Bool) -> Void)?
weak var currentTab: Tab?

lazy var popOver: CookieConsentPopover = {
let popover = CookieConsentPopover()
popover.delegate = self
return popover
}()
private(set) var popOver: CookieConsentPopover?

func cookieConsentPopover(_ popOver: CookieConsentPopover, didFinishWithResult result: Bool) {
popOver.close(animated: true)
popOver.close(animated: true) { [weak self] in
self?.popOver = nil
self?.currentTab = nil
}

if let completion = completion {
completion(result)
}
}

func show(on view: NSView, animated: Bool, result: ((Bool) -> Void)? = nil) {
preparePopover()

guard let popOver = popOver else {
return
}

func show(on view: NSView, animated: Bool, result: @escaping (Bool) -> Void) {
popOver.show(on: view, animated: true)
self.completion = result
popOver.show(on: view, animated: animated)
if let result = result {
self.completion = result
}
}

func close(animated: Bool) {
guard let popOver = popOver else {
return
}

popOver.close(animated: animated)
}

private func preparePopover() {
// If the tab was closed, we want to start the animation again
if currentTab == nil {
popOver = nil
}

guard popOver == nil else {
return
}

popOver = CookieConsentPopover()
popOver?.delegate = self
}
}
8 changes: 1 addition & 7 deletions DuckDuckGo/Autofill/ContentOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,7 @@ public final class ContentOverlayViewController: NSViewController, EmailManagerR
completion: @escaping (Data?, Error?) -> Void) {
let currentQueue = OperationQueue.current

let finalURL: URL

if let parameters = parameters {
finalURL = (try? url.addParameters(parameters)) ?? url
} else {
finalURL = url
}
let finalURL = (try? url.appendingParameters(parameters ?? [:])) ?? url

var request = URLRequest(url: finalURL, timeoutInterval: timeoutInterval)
request.allHTTPHeaderFields = headers
Expand Down
6 changes: 3 additions & 3 deletions DuckDuckGo/Bookmarks/Services/BookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ final class LocalBookmarkStore: BookmarkStore {
try self.context.save()
} catch {
assertionFailure("LocalBookmarkStore: Saving of context failed")
DispatchQueue.main.async { completion(false, error) }
DispatchQueue.main.async { completion(true, error) }
return
}

Expand Down Expand Up @@ -232,7 +232,7 @@ final class LocalBookmarkStore: BookmarkStore {
try self.context.save()
} catch {
assertionFailure("LocalBookmarkStore: Saving of context failed")
DispatchQueue.main.async { completion(false, error) }
DispatchQueue.main.async { completion(true, error) }
}

DispatchQueue.main.async { completion(true, nil) }
Expand Down Expand Up @@ -405,7 +405,7 @@ final class LocalBookmarkStore: BookmarkStore {
assertionFailure("LocalBookmarkStore: Saving of context failed")
}

DispatchQueue.main.async { completion(false, error) }
DispatchQueue.main.async { completion(true, error) }
return
}

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Bookmarks/ViewModel/BookmarkViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct BookmarkViewModel {
preconditionFailure("\(#file): Attempted to provide representing character for non-Bookmark")
}

return bookmark.url.host?.dropWWW().first?.uppercased() ?? "-"
return bookmark.url.host?.droppingWwwPrefix().first?.uppercased() ?? "-"
}

}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Browser Tab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ final class Tab: NSObject, Identifiable, ObservableObject {

// Add to local history
if let host = url.host, !host.isEmpty {
localHistory.insert(host.dropWWW())
localHistory.insert(host.droppingWwwPrefix())
}
}

Expand Down
14 changes: 8 additions & 6 deletions DuckDuckGo/Browser Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ final class BrowserTabViewController: NSViewController {
private func windowWillClose(_ notification: NSNotification) {
self.removeWebViewFromHierarchy()
}

private func subscribeToSelectedTabViewModel() {
tabCollectionViewModel.$selectedTabViewModel
.sink { [weak self] selectedTabViewModel in
Expand All @@ -128,12 +128,14 @@ final class BrowserTabViewController: NSViewController {
}
.store(in: &cancellables)
}

private func showCookieConsentPopoverIfNecessary(_ selectedTabViewModel: TabViewModel?) {
if selectedTabViewModel?.tab == cookieConsentPopoverManager.currentTab {
cookieConsentPopoverManager.popOver.show(on: view, animated: false)
if let selectedTab = selectedTabViewModel?.tab,
let cookiePopoverTab = cookieConsentPopoverManager.currentTab,
selectedTab == cookiePopoverTab {
cookieConsentPopoverManager.show(on: view, animated: false)
} else {
cookieConsentPopoverManager.popOver.close(animated: false)
cookieConsentPopoverManager.close(animated: false)
}
}

Expand Down Expand Up @@ -475,7 +477,7 @@ extension BrowserTabViewController: TabDelegate {

func tab(_ tab: Tab, promptUserForCookieConsent result: @escaping (Bool) -> Void) {
cookieConsentPopoverManager.show(on: view, animated: true, result: result)
cookieConsentPopoverManager.currentTab = tabViewModel?.tab
cookieConsentPopoverManager.currentTab = tab
}

func tabWillStartNavigation(_ tab: Tab, isUserInitiated: Bool) {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Browser Tab/ViewModel/TabViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ final class TabViewModel {
guard !errorViewState.isVisible else {
let failingUrl = tab.error?.failingUrl
addressBarString = failingUrl?.absoluteString ?? ""
passiveAddressBarString = failingUrl?.host?.drop(prefix: URL.HostPrefix.www.separated()) ?? ""
passiveAddressBarString = failingUrl?.host?.droppingWwwPrefix() ?? ""
return
}

Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Browser Tab/ViewModel/WebViewStateObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ final class WebViewStateObserver: NSObject {
}

private func updateTitle() {
if webView?.title?.trimmingWhitespaces().isEmpty ?? true {
tabViewModel?.tab.title = webView?.url?.host?.dropWWW()
if webView?.title?.trimmingWhitespace().isEmpty ?? true {
tabViewModel?.tab.title = webView?.url?.host?.droppingWwwPrefix()
return
}

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Extensions/FileManagerExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension FileManager {
}

let ownerDirectory = destURL.deletingLastPathComponent()
let fileNameWithoutExtension = destURL.lastPathComponent.drop(suffix: suffix)
let fileNameWithoutExtension = destURL.lastPathComponent.dropping(suffix: suffix)

for copy in 0... {
let destURL: URL = {
Expand Down
Loading

0 comments on commit e36ef59

Please sign in to comment.