Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Make componentId non optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cuba committed Oct 23, 2023
1 parent e8d7c82 commit c0d517c
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Sources/Brave/Frontend/Browser/Helpers/LaunchHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ private extension FilterListStorage {
if filterLists.isEmpty {
// If we don't have filter lists yet loaded, use the settings
return Set(allFilterListSettings.compactMap { setting in
guard let componentId = setting.componentId else { return nil }
return .filterList(
componentId: componentId,
componentId: setting.componentId,
isAlwaysAggressive: setting.isAlwaysAggressive
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public actor FilterListResourceDownloader {
do {
try await filterListSettings.asyncConcurrentForEach { setting in
guard await setting.isEnabled == true else { return }
guard let componentId = await setting.componentId else { return }
let componentId = await setting.componentId
guard FilterList.disabledComponentIDs.contains(componentId) else { return }

// Try to load the filter list folder. We always have to compile this at start
Expand Down
3 changes: 2 additions & 1 deletion Sources/Brave/WebFilters/FilterListStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import Combine
func loadFilterListSettings() {
var componentIds: Set<String> = []
allFilterListSettings = FilterListSetting.loadAllSettings(fromMemory: !persistChanges).filter({ setting in
guard let componentId = setting.componentId, !componentId.isEmpty, !componentIds.contains(componentId) else {
let componentId = setting.componentId
guard !componentId.isEmpty, !componentIds.contains(componentId) else {
setting.delete(inMemory: persistChanges)
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ public actor AdBlockStats {

extension FilterListSetting {
@MainActor var engineSource: CachedAdBlockEngine.Source? {
guard let componentId = componentId else { return nil }
return .filterList(componentId: componentId)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Data/models/FilterListSetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class FilterListSetting: NSManagedObject, CRUD {
}

@MainActor @NSManaged public var uuid: String
@MainActor @NSManaged public var componentId: String?
@MainActor @NSManaged public var componentId: String
@MainActor @NSManaged public var isEnabled: Bool
@MainActor @NSManaged public var isAlwaysAggressive: Bool
@MainActor @NSManaged public var order: NSNumber?
Expand All @@ -39,7 +39,7 @@ public final class FilterListSetting: NSManagedObject, CRUD {

/// Create a filter list setting for the given UUID and enabled status
@MainActor public class func create(
uuid: String, componentId: String?, isEnabled: Bool, order: Int, inMemory: Bool, isAlwaysAggressive: Bool
uuid: String, componentId: String, isEnabled: Bool, order: Int, inMemory: Bool, isAlwaysAggressive: Bool
) -> FilterListSetting {
var newSetting: FilterListSetting!

Expand Down
2 changes: 1 addition & 1 deletion Sources/Data/models/Model.xcdatamodeld/.xccurrentversion
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>Model24.xcdatamodel</string>
<string>Model25.xcdatamodel</string>
</dict>
</plist>
234 changes: 234 additions & 0 deletions Sources/Data/models/Model.xcdatamodeld/Model25.xcdatamodel/contents

Large diffs are not rendered by default.

0 comments on commit c0d517c

Please sign in to comment.