-
Notifications
You must be signed in to change notification settings - Fork 9
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
24 changed files
with
271 additions
and
136 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
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
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
27 changes: 27 additions & 0 deletions
27
RadixWallet/Clients/ResourcesVisibilityClient/ResourcesVisibilityClient+Interface.swift
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,27 @@ | ||
// MARK: - ResourcesVisibilityClient | ||
/// Controls the visibility of resources in the Wallet | ||
public struct ResourcesVisibilityClient: Sendable { | ||
public var hide: Hide | ||
public var getHidden: GetHidden | ||
public var hiddenValues: HiddenValues | ||
} | ||
|
||
extension ResourcesVisibilityClient { | ||
public typealias Hide = @Sendable (ResourceIdentifier, Bool) async throws -> Void | ||
public typealias GetHidden = @Sendable () async throws -> [ResourceIdentifier] | ||
public typealias HiddenValues = @Sendable () async -> AnyAsyncSequence<[ResourceIdentifier]> | ||
} | ||
|
||
extension ResourcesVisibilityClient { | ||
public func hide(_ resource: ResourceIdentifier) async throws { | ||
try await hide(resource, true) | ||
} | ||
|
||
public func unhide(_ resource: ResourceIdentifier) async throws { | ||
try await hide(resource, false) | ||
} | ||
|
||
public func isHidden(_ resource: ResourceIdentifier) async throws -> Bool { | ||
try await getHidden().contains(resource) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
RadixWallet/Clients/ResourcesVisibilityClient/ResourcesVisibilityClient+Live.swift
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,23 @@ | ||
extension ResourcesVisibilityClient: DependencyKey { | ||
public typealias Value = ResourcesVisibilityClient | ||
|
||
public static let liveValue: Self = .live() | ||
|
||
public static func live( | ||
profileStore: ProfileStore = .shared | ||
) -> Self { | ||
.init( | ||
hide: { resource, hide in | ||
try await profileStore.updatingOnCurrentNetwork { network in | ||
hide ? network.resourcePreferences.hideResource(resource: resource) : network.resourcePreferences.unhideResource(resource: resource) | ||
} | ||
}, | ||
getHidden: { | ||
try await profileStore.network().getHiddenResources() | ||
}, | ||
hiddenValues: { | ||
await profileStore.hiddenResourcesValues() | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.