mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Supports blocking third-party sources
Blocked sources cannot be added by new users, or updated for existing users.
This commit is contained in:
@@ -118,3 +118,40 @@ public extension UserDefaults
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension UserDefaults
|
||||
{
|
||||
// Cache trustedSourceIDs just in case we need to check whether source is trusted or not.
|
||||
@nonobjc var trustedSourceIDs: Set<String>? {
|
||||
get {
|
||||
guard let sourceIDs = _trustedSourceIDs else { return nil }
|
||||
return Set(sourceIDs)
|
||||
}
|
||||
set {
|
||||
_trustedSourceIDs = newValue?.map { $0 }
|
||||
}
|
||||
}
|
||||
@NSManaged @objc(trustedSourceIDs) private var _trustedSourceIDs: [String]?
|
||||
|
||||
@nonobjc var blockedSourceIDs: Set<String>? {
|
||||
get {
|
||||
guard let sourceIDs = _blockedSourceIDs else { return nil }
|
||||
return Set(sourceIDs)
|
||||
}
|
||||
set {
|
||||
_blockedSourceIDs = newValue?.map { $0 }
|
||||
}
|
||||
}
|
||||
@NSManaged @objc(blockedSourceIDs) private var _blockedSourceIDs: [String]?
|
||||
|
||||
@nonobjc var blockedSourceURLs: Set<URL>? {
|
||||
get {
|
||||
guard let sourceURLs = _blockedSourceURLs?.compactMap({ URL(string: $0) }) else { return nil }
|
||||
return Set(sourceURLs)
|
||||
}
|
||||
set {
|
||||
_blockedSourceURLs = newValue?.map { $0.absoluteString }
|
||||
}
|
||||
}
|
||||
@NSManaged @objc(blockedSourceURLs) private var _blockedSourceURLs: [String]?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user