Skip to content

Commit

Permalink
merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbzurovski committed Sep 6, 2024
2 parents 4168edb + 405f170 commit 64bbc6f
Show file tree
Hide file tree
Showing 24 changed files with 271 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Aux/Config/Common.xcconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MARK: - Custom flags

/// Application version shared across all targets and flavours
APP_VERSION = 1.8.3
APP_VERSION = 1.9.0

/// App Icon base name
APP_ICON = AppIcon
Expand Down
66 changes: 43 additions & 23 deletions RadixWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@
5B45E3012BC5A491007C4C84 /* FactorSourceAccess+ViewState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B45E3002BC5A491007C4C84 /* FactorSourceAccess+ViewState.swift */; };
5B4712CC2C526146003B4712 /* HeaderButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B4712CB2C526146003B4712 /* HeaderButtonStyle.swift */; };
5B526ADB2C876E7C00AF8B72 /* AccountLockerClaimDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B526ADA2C876E7C00AF8B72 /* AccountLockerClaimDetails.swift */; };
5B526AEC2C89C3C200AF8B72 /* ResourcesVisibilityClient+Interface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B526AE82C89C3C200AF8B72 /* ResourcesVisibilityClient+Interface.swift */; };
5B526AED2C89C3C200AF8B72 /* ResourcesVisibilityClient+Live.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B526AE92C89C3C200AF8B72 /* ResourcesVisibilityClient+Live.swift */; };
5B526AEE2C89C3C200AF8B72 /* ResourcesVisibilityClient+Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B526AEA2C89C3C200AF8B72 /* ResourcesVisibilityClient+Test.swift */; };
5B6499B72BCFD0E8000F2176 /* SecurityFactors+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6499B52BCFD0E8000F2176 /* SecurityFactors+View.swift */; };
5B6499B82BCFD0E8000F2176 /* SecurityFactors+Reducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6499B62BCFD0E8000F2176 /* SecurityFactors+Reducer.swift */; };
5B6499BA2BCFDB1E000F2176 /* ShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6499B92BCFDB1E000F2176 /* ShareView.swift */; };
Expand Down Expand Up @@ -1945,6 +1948,9 @@
5B45E3002BC5A491007C4C84 /* FactorSourceAccess+ViewState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FactorSourceAccess+ViewState.swift"; sourceTree = "<group>"; };
5B4712CB2C526146003B4712 /* HeaderButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderButtonStyle.swift; sourceTree = "<group>"; };
5B526ADA2C876E7C00AF8B72 /* AccountLockerClaimDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountLockerClaimDetails.swift; sourceTree = "<group>"; };
5B526AE82C89C3C200AF8B72 /* ResourcesVisibilityClient+Interface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ResourcesVisibilityClient+Interface.swift"; sourceTree = "<group>"; };
5B526AE92C89C3C200AF8B72 /* ResourcesVisibilityClient+Live.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ResourcesVisibilityClient+Live.swift"; sourceTree = "<group>"; };
5B526AEA2C89C3C200AF8B72 /* ResourcesVisibilityClient+Test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ResourcesVisibilityClient+Test.swift"; sourceTree = "<group>"; };
5B6499B52BCFD0E8000F2176 /* SecurityFactors+View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SecurityFactors+View.swift"; sourceTree = "<group>"; };
5B6499B62BCFD0E8000F2176 /* SecurityFactors+Reducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SecurityFactors+Reducer.swift"; sourceTree = "<group>"; };
5B6499B92BCFDB1E000F2176 /* ShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3059,11 +3065,11 @@
48CFBCEA2ADC10D800E77A5C /* CustomizeFees */ = {
isa = PBXGroup;
children = (
48CFBCEF2ADC10D800E77A5C /* AdvancedFeesCustomization.swift */,
48CFBCEB2ADC10D800E77A5C /* AdvancedFeesCustomization+View.swift */,
48CFBCEE2ADC10D800E77A5C /* NormalFeesCustomization.swift */,
48CFBCEC2ADC10D800E77A5C /* NormalFeesCustomization+View.swift */,
48CFBCED2ADC10D800E77A5C /* FeesView.swift */,
48CFBCEE2ADC10D800E77A5C /* NormalFeesCustomization.swift */,
48CFBCEF2ADC10D800E77A5C /* AdvancedFeesCustomization.swift */,
48CFBCF02ADC10D800E77A5C /* CustomizeFees+View.swift */,
48CFBCF12ADC10D800E77A5C /* CustomizeFees.swift */,
);
Expand Down Expand Up @@ -4397,57 +4403,58 @@
isa = PBXGroup;
children = (
5B3C48B32C80D0FF00DB160D /* AccountLockersClient */,
5BBC7D9D2C3D390D00B04BD6 /* BootstrapClient */,
5B272DD52C36E88700B74F1F /* AppEventsClient */,
A4DCCC4C2C2DA23E00438A7B /* HomeCardsClient */,
8329ACE22BBAB9CD005FD9DC /* DeepLinkHandlerClient */,
E7A5AC942C09F428006CB6EC /* ResetWalletClient */,
A4ECE2782BEEB01800468BF6 /* CloudBackupClient */,
A4ECE2712BEEAFFC00468BF6 /* SecurityCenterClient */,
5B2A45002BD667FB00AEC8AD /* ContactSupportClient */,
5B9846BE2BBD5EF600E814F3 /* SensitiveInfoClient */,
5B1C4FD62BBB0C0100B9436F /* AppsFlyerClient */,
8370FC5A2B99C732007AD882 /* NPSSurveyClient */,
83823EA82B72362600827211 /* TokenPriceClient */,
83823EA52B722D9000827211 /* HTTPClient */,
A462B5752B820D1200C26D20 /* TransactionHistoryClient */,
A47572002B29B3B90059A95D /* IOSSecurityClient */,
830EA9D92AEA8750004C8051 /* EntitiesVisibilityClient */,
48CFBF8D2ADC10D900E77A5C /* AccountPortfoliosClient */,
48CFBF622ADC10D900E77A5C /* AccountsClient */,
5B272DD52C36E88700B74F1F /* AppEventsClient */,
48CFBF6C2ADC10D900E77A5C /* AppPreferencesClient */,
5B1C4FD62BBB0C0100B9436F /* AppsFlyerClient */,
48CFBF652ADC10D900E77A5C /* AuthorizedDappsClient */,
48CFBFAE2ADC10D900E77A5C /* TransportProfileClient */,
5BBC7D9D2C3D390D00B04BD6 /* BootstrapClient */,
48CFBF772ADC10D900E77A5C /* CacheClient */,
48CFC0D62ADC10D900E77A5C /* CameraPermissionClient */,
A4ECE2782BEEB01800468BF6 /* CloudBackupClient */,
5B2A45002BD667FB00AEC8AD /* ContactSupportClient */,
48CFBF562ADC10D900E77A5C /* DappInteractionClient */,
8329ACE22BBAB9CD005FD9DC /* DeepLinkHandlerClient */,
48CFBFA22ADC10D900E77A5C /* DeviceFactorSourceClient */,
48CFBFC32ADC10D900E77A5C /* DiskPersistenceClient */,
830EA9D92AEA8750004C8051 /* EntitiesVisibilityClient */,
48CFBF532ADC10D900E77A5C /* FactorSourcesClient */,
48CFC0CC2ADC10D900E77A5C /* FaucetClient */,
48CFBFC72ADC10D900E77A5C /* GatewayAPI */,
48CFBFA62ADC10D900E77A5C /* GatewaysClient */,
A4DCCC4C2C2DA23E00438A7B /* HomeCardsClient */,
83823EA52B722D9000827211 /* HTTPClient */,
48CFBF912ADC10D900E77A5C /* ImportLegacyWalletClient */,
A47572002B29B3B90059A95D /* IOSSecurityClient */,
48CFBF0C2ADC10D900E77A5C /* KeychainClient */,
48CFBF7B2ADC10D900E77A5C /* LedgerHardwareWalletClient */,
48CFBFA92ADC10D900E77A5C /* LocalAuthenticationClient */,
48CFBF682ADC10D900E77A5C /* MnemonicClient */,
48CFBF712ADC10D900E77A5C /* NetworkSwitchingClient */,
8370FC5A2B99C732007AD882 /* NPSSurveyClient */,
48CFBF5F2ADC10D900E77A5C /* OnboardingClient */,
48CFBFBB2ADC10D900E77A5C /* OnLedgerEntitiesClient */,
48CFBF8A2ADC10D900E77A5C /* OverlayWindowClient */,
48CFBF7F2ADC10D900E77A5C /* P2PLinksClient */,
48CFBF232ADC10D900E77A5C /* PasteboardClient */,
48CFBF972ADC10D900E77A5C /* PersonasClient */,
48CFC0DC2ADC10D900E77A5C /* ProfileStore */,
48CFBFB82ADC10D900E77A5C /* QRGeneratorClient */,
48CFBF592ADC10D900E77A5C /* RadixConnectClient */,
E7A5AC942C09F428006CB6EC /* ResetWalletClient */,
5B526AEB2C89C3C200AF8B72 /* ResourcesVisibilityClient */,
48CFBFB32ADC10D900E77A5C /* ROLAClient */,
48CFC0C82ADC10D900E77A5C /* SecureStorageClient */,
A4ECE2712BEEAFFC00468BF6 /* SecurityCenterClient */,
5B9846BE2BBD5EF600E814F3 /* SensitiveInfoClient */,
48CFC0D02ADC10D900E77A5C /* SubmitTransactionClient */,
83823EA82B72362600827211 /* TokenPriceClient */,
48CFBF822ADC10D900E77A5C /* TransactionClient */,
48CFBF0C2ADC10D900E77A5C /* KeychainClient */,
48CFBF172ADC10D900E77A5C /* UserDefaults+Dependency+Extension */,
48CFBF232ADC10D900E77A5C /* PasteboardClient */,
A462B5752B820D1200C26D20 /* TransactionHistoryClient */,
48CFBFAE2ADC10D900E77A5C /* TransportProfileClient */,
48CFC0C52ADC10D900E77A5C /* URLFormatterClient */,
48CFBF172ADC10D900E77A5C /* UserDefaults+Dependency+Extension */,
);
path = Clients;
sourceTree = "<group>";
Expand Down Expand Up @@ -5514,6 +5521,16 @@
path = FactorSourceAccess;
sourceTree = "<group>";
};
5B526AEB2C89C3C200AF8B72 /* ResourcesVisibilityClient */ = {
isa = PBXGroup;
children = (
5B526AE82C89C3C200AF8B72 /* ResourcesVisibilityClient+Interface.swift */,
5B526AE92C89C3C200AF8B72 /* ResourcesVisibilityClient+Live.swift */,
5B526AEA2C89C3C200AF8B72 /* ResourcesVisibilityClient+Test.swift */,
);
path = ResourcesVisibilityClient;
sourceTree = "<group>";
};
5B6499B42BCFD0C7000F2176 /* SecurityFactors */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -7346,6 +7363,7 @@
5B80FCC42C298E68008444F5 /* ArbitraryDataFieldView.swift in Sources */,
8370FC5C2B99C780007AD882 /* NPSSurveyClient+Interface.swift in Sources */,
5B3C48B52C80D11E00DB160D /* AccountLockersClient+Interface.swift in Sources */,
5B526AED2C89C3C200AF8B72 /* ResourcesVisibilityClient+Live.swift in Sources */,
A408155B2C7E0D08005E65B9 /* AccountDepositPreValidationResourceSpecificBehaviourItem.swift in Sources */,
5B4712CC2C526146003B4712 /* HeaderButtonStyle.swift in Sources */,
48D5F38C2BD8DDB9000DE964 /* DebugKeychainTest.swift in Sources */,
Expand Down Expand Up @@ -7470,6 +7488,7 @@
48CFC5732ADC10DA00E77A5C /* Configuration.swift in Sources */,
A40815882C7E0D08005E65B9 /* ManifestClass.swift in Sources */,
48CFC5A42ADC10DA00E77A5C /* PrimaryTextButtonStyle.swift in Sources */,
5B526AEE2C89C3C200AF8B72 /* ResourcesVisibilityClient+Test.swift in Sources */,
A408160B2C7E0D08005E65B9 /* StateEntityDetailsResponseItemAncestorIdentities.swift in Sources */,
A4DCCC522C2DA33300438A7B /* HomeCardsClient+Test.swift in Sources */,
A40815DA2C7E0D08005E65B9 /* ProgrammaticScryptoSborValueKind.swift in Sources */,
Expand Down Expand Up @@ -7597,6 +7616,7 @@
48CFC2CE2ADC10D900E77A5C /* ReceivingAccount+Reducer.swift in Sources */,
5B3C48B92C80D23F00DB160D /* AccountLockersClient+Test.swift in Sources */,
48CFC3722ADC10D900E77A5C /* LSUDetails+View.swift in Sources */,
5B526AEC2C89C3C200AF8B72 /* ResourcesVisibilityClient+Interface.swift in Sources */,
48CFC47E2ADC10DA00E77A5C /* OverlayWindowClient+Live.swift in Sources */,
A408158B2C7E0D08005E65B9 /* MetadataDecimalArrayValue.swift in Sources */,
48CFC4722ADC10DA00E77A5C /* P2PLinksClient+Live.swift in Sources */,
Expand Down Expand Up @@ -8953,7 +8973,7 @@
repositoryURL = "https://github.com/radixdlt/sargon";
requirement = {
kind = exactVersion;
version = 1.0.44;
version = 1.0.45;
};
};
A415574E2B757C5E0040AD4E /* XCRemoteSwiftPackageReference "swift-composable-architecture" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/sargon",
"state" : {
"revision" : "e4760bf858dd98bc0e713e4dae44a70f12eac1a4",
"version" : "1.0.44"
"revision" : "f55d4ee922711a6ab8642516e657e388c51ce348",
"version" : "1.0.45"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extension AccountPortfoliosClient: DependencyKey {
@Dependency(\.cacheClient) var cacheClient
@Dependency(\.tokenPricesClient) var tokenPricesClient
@Dependency(\.appPreferencesClient) var appPreferencesClient
@Dependency(\.resourcesVisibilityClient) var resourcesVisibilityClient
@Dependency(\.gatewaysClient) var gatewaysClient

/// Update currency amount visibility based on the profile state
Expand All @@ -27,10 +28,9 @@ extension AccountPortfoliosClient: DependencyKey {

/// Update when hidden resources change
Task {
for try await _ in await appPreferencesClient.appPreferenceUpdates().removeDuplicates(by: { $0.resources.hiddenResources == $1.resources.hiddenResources }) {
for try await hiddenResources in await resourcesVisibilityClient.hiddenValues().removeDuplicates() {
guard !Task.isCancelled else { return }
let accountAddresses = state.portfoliosSubject.value.wrappedValue.map { $0.map(\.key) } ?? []
_ = try await fetchAccountPortfolios(accountAddresses, forceRefreshEntities: false, forceRefreshPrices: true)
await state.updatePortfoliosHiddenResources(hiddenResources: hiddenResources)
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ extension AccountPortfoliosClient: DependencyKey {
await state.setIsCurrencyAmountVisble(display.isCurrencyAmountVisible)

let accounts = try await onLedgerEntitiesClient.getAccounts(accountAddresses)
let hiddenResources = preferences.resources.hiddenResources
let hiddenResources = try await resourcesVisibilityClient.getHidden()

let portfolios = accounts.map { AccountPortfolio(account: $0, hiddenResources: hiddenResources) }
await state.handlePortfoliosUpdate(portfolios)
Expand Down Expand Up @@ -152,7 +152,7 @@ extension AccountPortfoliosClient: DependencyKey {
}

let account = try await onLedgerEntitiesClient.getAccount(accountAddress)
let hiddenResources = await appPreferencesClient.getHiddenResources()
let hiddenResources = try await resourcesVisibilityClient.getHidden()
let portfolio = AccountPortfolio(account: account, hiddenResources: hiddenResources)

if case let .success(tokenPrices) = await state.tokenPrices {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import Foundation
// MARK: - Definition
extension AccountPortfoliosClient {
public struct AccountPortfolio: Sendable, Hashable, CustomDebugStringConvertible {
/// The visible account to consumers of this portfolio. It has already removed any reference to hidden resources.
public var account: OnLedgerEntity.OnLedgerAccount
public let hiddenResources: [ResourceIdentifier]

/// The original account, without any modifications made. Necessary for whenever we need to update the hidden resources.
private let originalAccount: OnLedgerEntity.OnLedgerAccount

private(set) var hiddenResources: [ResourceIdentifier]

public var poolUnitDetails: Loadable<[OnLedgerEntitiesClient.OwnedResourcePoolDetails]> = .idle
public var stakeUnitDetails: Loadable<IdentifiedArrayOf<OnLedgerEntitiesClient.OwnedStakeDetails>> = .idle

Expand All @@ -15,6 +21,17 @@ extension AccountPortfoliosClient {
}

init(account: OnLedgerEntity.OnLedgerAccount, hiddenResources: [ResourceIdentifier]) {
self.originalAccount = account
self.hiddenResources = hiddenResources
self.account = Self.removeHiddenResourcesFromAccount(account: account, hiddenResources: hiddenResources)
}

mutating func updateHiddenResources(hiddenResources: [ResourceIdentifier]) {
self.hiddenResources = hiddenResources
self.account = Self.removeHiddenResourcesFromAccount(account: originalAccount, hiddenResources: hiddenResources)
}

private static func removeHiddenResourcesFromAccount(account: OnLedgerEntity.OnLedgerAccount, hiddenResources: [ResourceIdentifier]) -> OnLedgerEntity.OnLedgerAccount {
var modified = account

// Remove every hidden fungible resource
Expand All @@ -32,8 +49,7 @@ extension AccountPortfoliosClient {
hiddenResources.contains(.poolUnit(poolUnit.resourcePoolAddress))
})

self.account = modified
self.hiddenResources = hiddenResources
return modified
}
}

Expand Down Expand Up @@ -70,6 +86,16 @@ extension AccountPortfoliosClient.State {
setOrUpdateAccountPortfolios(portfolios)
}

func updatePortfoliosHiddenResources(hiddenResources: [ResourceIdentifier]) {
if var existingPortfolios = portfoliosSubject.value.values.wrappedValue.map({ Array($0) }) {
existingPortfolios.mutateAll { portfolio in
portfolio.updateHiddenResources(hiddenResources: hiddenResources)
}
applyTokenPrices(to: &existingPortfolios)
setOrUpdateAccountPortfolios(existingPortfolios)
}
}

func portfolioForAccount(_ address: AccountAddress) -> AnyAsyncSequence<AccountPortfoliosClient.AccountPortfolio> {
portfoliosSubject.compactMap { $0[address].unwrap()?.wrappedValue }.removeDuplicates().eraseToAnyAsyncSequence()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ extension AppPreferencesClient {
display.isCurrencyAmountVisible.toggle()
}
}

public func getHiddenResources() async -> [ResourceIdentifier] {
await getPreferences().resources.hiddenResources
}

public func isResourceHidden(_ resource: ResourceIdentifier) async -> Bool {
await getHiddenResources().contains(resource)
}
}

// MARK: AppPreferencesClient.Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extension OnLedgerEntitiesClient {
let amount = resourceQuantifier.amount
let resourceAddress = resource.resourceAddress

@Dependency(\.appPreferencesClient) var appPreferencesClient
let hiddenResources = await appPreferencesClient.getHiddenResources()
@Dependency(\.resourcesVisibilityClient) var resourcesVisibilityClient
let hiddenResources = try await resourcesVisibilityClient.getHidden()

let guarantee: TransactionGuarantee? = { () -> TransactionGuarantee? in
guard case let .predicted(predictedAmount) = resourceQuantifier else { return nil }
Expand Down Expand Up @@ -200,8 +200,8 @@ extension OnLedgerEntitiesClient {

switch resourceInfo {
case let .left(resource):
@Dependency(\.appPreferencesClient) var appPreferencesClient
let hiddenResources = await appPreferencesClient.getHiddenResources()
@Dependency(\.resourcesVisibilityClient) var resourcesVisibilityClient
let hiddenResources = try await resourcesVisibilityClient.getHidden()

let existingTokenIds = ids.filter { id in
!newlyCreatedNonFungibles.contains { newId in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ extension ProfileStore {
}
}

/// A multicasting replaying AsyncSequence of distinct Personas for the currently selected network.
public func hiddenResourcesValues() -> AnyAsyncSequence<[ResourceIdentifier]> {
_lens {
$0.network?.getHiddenResources()
}
}

/// A multicasting replaying AsyncSequence of distinct Gateways
public func currentGatewayValues() -> AnyAsyncSequence<Gateway> {
_lens {
Expand Down
3 changes: 2 additions & 1 deletion RadixWallet/Clients/ProfileStore/ProfileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ extension ProfileStore {
id: .mainnet,
accounts: accounts.elements, // FIXME: Declare init in (Swift)Sargon accepting `Accounts` (IdentifiedArrayOf<Account>) ?
personas: [],
authorizedDapps: []
authorizedDapps: [],
resourcePreferences: []
)

var lastUsedOnDevice = creatingDevice
Expand Down
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)
}
}
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()
}
)
}
}
Loading

0 comments on commit 64bbc6f

Please sign in to comment.