Skip to content

Commit

Permalink
Merge branch 'release/0.28.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Sep 17, 2022
2 parents cdf49bf + 78de55d commit 78326e5
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 88 deletions.
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.28.8
MARKETING_VERSION = 0.28.9

2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6234,7 +6234,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 28.1.0;
version = 29.0.0;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
11 changes: 2 additions & 9 deletions DuckDuckGo/API/APIRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,10 @@ enum APIRequest {
allowedQueryReservedCharacters: CharacterSet? = nil,
headers: HTTPHeaders = APIHeaders().defaultHeaders,
timeoutInterval: TimeInterval = 60.0) -> URLRequest {
let url = (try? parameters?.reduce(url) { partialResult, parameter in
try partialResult.appendingParameter(
name: parameter.key,
value: parameter.value,
allowedReservedCharacters: allowedQueryReservedCharacters
)
}) ?? url
var urlRequest = URLRequest(url: url)
let url = url.appendingParameters(parameters ?? [:], allowedReservedCharacters: allowedQueryReservedCharacters)
var urlRequest = URLRequest(url: url, timeoutInterval: timeoutInterval)
urlRequest.allHTTPHeaderFields = headers
urlRequest.httpMethod = method.rawValue
urlRequest.timeoutInterval = timeoutInterval
return urlRequest
}

Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Autoconsent/AutoconsentUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ extension AutoconsentUserScript {
let script = """
(() => {
try {
return !!(\(messageData.code))
return !!(\(messageData.code));
} catch (e) {
// ignore CSP errors
// ignore any errors
return;
}
})();
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

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

let finalURL = (try? url.appendingParameters(parameters ?? [:])) ?? url
let finalURL = url.appendingParameters(parameters ?? [:])

var request = URLRequest(url: finalURL, timeoutInterval: timeoutInterval)
request.allHTTPHeaderFields = headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ final class BookmarksBarViewController: NSViewController {

@objc
private func frameChangeNotification() {
viewModel.clipOrRestoreBookmarksBarItems()
refreshClippedIndicator()
// Wait until the frame change has taken effect for subviews before calculating changes to the list of items.
DispatchQueue.main.async {
self.viewModel.clipOrRestoreBookmarksBarItems()
self.refreshClippedIndicator()
}
}

override func removeFromParent() {
Expand Down
17 changes: 11 additions & 6 deletions DuckDuckGo/Bookmarks Bar/View/BookmarksBarViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,18 @@ final class BookmarksBarViewModel: NSObject {
}

if bookmarksBarItemsTotalWidth >= clipThreshold {
if clipLastBarItem() {
delegate?.bookmarksBarViewModelReloadedData()
while bookmarksBarItemsTotalWidth >= clipThreshold {
if !clipLastBarItem() {
// Short circuit the while loop in the case that clipping the last item doesn't succeed.
break
}
}
} else if let nextRestorableClippedItem = clippedItems.first {

delegate?.bookmarksBarViewModelReloadedData()
} else if !clippedItems.isEmpty {
var restoredItem = false

while true {
while let nextRestorableClippedItem = clippedItems.first {
if !restoreNextClippedItemToBookmarksBarIfPossible(item: nextRestorableClippedItem) {
break
}
Expand Down Expand Up @@ -223,11 +228,11 @@ final class BookmarksBarViewModel: NSObject {
textSizeCalculationLabel.stringValue = buttonTitle
textSizeCalculationLabel.sizeToFit()

let cappedTitleWidth = min(Constants.maximumButtonWidth, textSizeCalculationLabel.frame.width)
let cappedTitleWidth = ceil(min(Constants.maximumButtonWidth, textSizeCalculationLabel.frame.width))
let calculatedWidth = min(Constants.maximumButtonWidth, textSizeCalculationLabel.frame.width) + Constants.additionalItemWidth
collectionViewItemSizeCache[buttonTitle] = cappedTitleWidth

return calculatedWidth
return ceil(calculatedWidth)
}
}

Expand Down
26 changes: 9 additions & 17 deletions DuckDuckGo/Common/Extensions/URLExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ extension URL {
return nil
}

do {
return try Self.duckDuckGo
.appendingParameter(name: DuckDuckGoParameters.search.rawValue, value: trimmedQuery)
} catch let error {
os_log("URL extension: %s", type: .error, error.localizedDescription)
return nil
}
return Self.duckDuckGo.appendingParameter(name: DuckDuckGoParameters.search.rawValue, value: trimmedQuery)
}

static func makeURL(from addressBarString: String) -> URL? {
Expand Down Expand Up @@ -130,26 +124,26 @@ extension URL {
return URL(string: Self.atb)!
}

static func searchAtb(atbWithVariant: String, setAtb: String) -> URL? {
return try? Self.initialAtb
static func searchAtb(atbWithVariant: String, setAtb: String) -> URL {
return Self.initialAtb
.appendingParameters([
DuckDuckGoParameters.ATB.atb: atbWithVariant,
DuckDuckGoParameters.ATB.setAtb: setAtb
])
}

static func appRetentionAtb(atbWithVariant: String, setAtb: String) -> URL? {
return try? Self.initialAtb
static func appRetentionAtb(atbWithVariant: String, setAtb: String) -> URL {
return Self.initialAtb
.appendingParameters([
DuckDuckGoParameters.ATB.activityType: DuckDuckGoParameters.ATB.appUsageValue,
DuckDuckGoParameters.ATB.atb: atbWithVariant,
DuckDuckGoParameters.ATB.setAtb: setAtb
])
}

static func exti(forAtb atb: String) -> URL? {
static func exti(forAtb atb: String) -> URL {
let extiUrl = URL(string: Self.exti)!
return try? extiUrl.appendingParameter(name: DuckDuckGoParameters.ATB.atb, value: atb)
return extiUrl.appendingParameter(name: DuckDuckGoParameters.ATB.atb, value: atb)
}

// MARK: - Components
Expand Down Expand Up @@ -290,15 +284,13 @@ extension URL {
absoluteString.starts(with: Self.duckDuckGo.absoluteString)
}

// swiftlint:disable unused_optional_binding
var isDuckDuckGoSearch: Bool {
if isDuckDuckGo, path.isEmpty || path == "/", let _ = try? getParameter(name: DuckDuckGoParameters.search.rawValue) {
if isDuckDuckGo, path.isEmpty || path == "/", getParameter(named: DuckDuckGoParameters.search.rawValue) != nil {
return true
}

return false
}
// swiftlint:enable unused_optional_binding

enum DuckDuckGoParameters: String {
case search = "q"
Expand All @@ -318,7 +310,7 @@ extension URL {

var searchQuery: String? {
guard isDuckDuckGoSearch else { return nil }
return try? getParameter(name: DuckDuckGoParameters.search.rawValue)
return getParameter(named: DuckDuckGoParameters.search.rawValue)
}

// MARK: - Punycode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import BrowserServicesKit
final class AppPrivacyConfigurationDataProvider: EmbeddedDataProvider {

public struct Constants {
public static let embeddedDataETag = "\"51df1b1e7a3e53ae15c31b89e1bfd6d5\""
public static let embeddedDataSHA = "674e0c3c5ef3db3841600f50dee5071f328710205e7b9791296b7417f619cfed"
public static let embeddedDataETag = "\"52d237343d238f07876c9ea06842cbea\""
public static let embeddedDataSHA = "e37e207881b8ec65cd23e6556a7cd03ef6a4339a0505ede053cb370e5cbe9989"
}

var embeddedDataEtag: String {
Expand Down
Loading

0 comments on commit 78326e5

Please sign in to comment.