-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,342 additions
and
470 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MARKETING_VERSION = 7.88.1 | ||
MARKETING_VERSION = 7.89.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// SyncSettingsAdapter.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import BrowserServicesKit | ||
import Combine | ||
import Common | ||
import DDGSync | ||
import Persistence | ||
import SyncDataProviders | ||
|
||
public final class SyncSettingsAdapter { | ||
|
||
public private(set) var provider: SettingsProvider? | ||
public private(set) var emailManager: EmailManager? | ||
public let syncDidCompletePublisher: AnyPublisher<Void, Never> | ||
|
||
public init() { | ||
syncDidCompletePublisher = syncDidCompleteSubject.eraseToAnyPublisher() | ||
} | ||
|
||
public func updateDatabaseCleanupSchedule(shouldEnable: Bool) { | ||
} | ||
|
||
public func setUpProviderIfNeeded(metadataDatabase: CoreDataDatabase, metadataStore: SyncMetadataStore) { | ||
guard provider == nil else { | ||
return | ||
} | ||
let emailManager = EmailManager() | ||
|
||
let provider = SettingsProvider( | ||
metadataDatabase: metadataDatabase, | ||
metadataStore: metadataStore, | ||
emailManager: emailManager, | ||
syncDidUpdateData: { [weak self] in | ||
self?.syncDidCompleteSubject.send() | ||
} | ||
) | ||
|
||
syncErrorCancellable = provider.syncErrorPublisher | ||
.sink { error in | ||
switch error { | ||
case let syncError as SyncError: | ||
Pixel.fire(pixel: .syncSettingsFailed, error: syncError) | ||
case let settingsMetadataError as SettingsSyncMetadataSaveError: | ||
let underlyingError = settingsMetadataError.underlyingError | ||
let processedErrors = CoreDataErrorsParser.parse(error: underlyingError as NSError) | ||
let params = processedErrors.errorPixelParameters | ||
Pixel.fire(pixel: .syncSettingsMetadataUpdateFailed, error: underlyingError, withAdditionalParameters: params) | ||
default: | ||
let nsError = error as NSError | ||
if nsError.domain != NSURLErrorDomain { | ||
let processedErrors = CoreDataErrorsParser.parse(error: error as NSError) | ||
let params = processedErrors.errorPixelParameters | ||
Pixel.fire(pixel: .syncSettingsFailed, error: error, withAdditionalParameters: params) | ||
} | ||
} | ||
os_log(.error, log: OSLog.syncLog, "Settings Sync error: %{public}s", String(reflecting: error)) | ||
} | ||
|
||
self.provider = provider | ||
self.emailManager = emailManager | ||
} | ||
|
||
private var syncDidCompleteSubject = PassthroughSubject<Void, Never>() | ||
private var syncErrorCancellable: AnyCancellable? | ||
} |
Oops, something went wrong.