Skip to content

Commit

Permalink
fix provider storage not setting properly
Browse files Browse the repository at this point in the history
  • Loading branch information
lykalabrada committed Oct 17, 2023
1 parent 787b5eb commit e950f88
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mobile-app/app/api/wallet/service_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ async function set(
url: NonNullable<string>,
type: CustomServiceProviderType = CustomServiceProviderType.DVM,
): Promise<void> {
const STORAGE_KEY =
type === CustomServiceProviderType.DVM ? KEY : `${KEY}.${type}`;
await SecuredStoreAPI.setItem(STORAGE_KEY, url);
await SecuredStoreAPI.setItem(`${KEY}.${type}`, url);
}

async function get(
type: CustomServiceProviderType = CustomServiceProviderType.DVM,
): Promise<string | undefined> {
const val = await SecuredStoreAPI.getItem(`${KEY}.${type}`);
const PROVIDER_KEY = `${KEY}.${type}`;
const val = await SecuredStoreAPI.getItem(PROVIDER_KEY);

if (type === CustomServiceProviderType.DVM && val === null) {
const existingDvm = await SecuredStoreAPI.getItem(KEY);
if (existingDvm !== null) {
await set(existingDvm, CustomServiceProviderType.DVM);
await SecuredStoreAPI.setItem(PROVIDER_KEY, existingDvm);
await SecuredStoreAPI.removeItem(KEY);
return existingDvm;
}
Expand Down

0 comments on commit e950f88

Please sign in to comment.