Skip to content

Commit

Permalink
feat: preserve tokenSales info in case fetching failed
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Nov 1, 2024
1 parent cb015ac commit 2c428bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const STORAGE_KEYS = {
fungibleTokenBalances: 'fungible-token-balances',
permissions: 'permissions',
appsBrowserHistory: 'apps-browser-history',
tokenSales: 'token-sales',
transactionsLatest: 'transactions-latest',
transactionsLoaded: 'transactions-loaded',
transactionsPending: 'transactions-pending',
Expand Down
9 changes: 6 additions & 3 deletions src/protocols/aeternity/composables/aeTokenSales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { computed, ref } from 'vue';
import camelCaseKeysDeep from 'camelcase-keys-deep';

import { ITokenSale } from '@/types';
import { NETWORK_TYPE_CUSTOM } from '@/constants';
import { NETWORK_TYPE_CUSTOM, STORAGE_KEYS } from '@/constants';
import {
createCustomScopedComposable,
fetchAllPages,
Expand All @@ -12,6 +12,7 @@ import {
import { useNetworks } from '@/composables';
import { AE_TOKEN_SALES_URLS } from '@/protocols/aeternity/config';
import { createPollingBasedOnMountedComponents } from '@/composables/composablesHelpers';
import { useStorageRef } from '@/composables/storageRef';

const POLLING_INTERVAL = 60000;

Expand All @@ -26,7 +27,10 @@ const initPollingWatcher = createPollingBasedOnMountedComponents(POLLING_INTERVA
/**
* List of all token sales available
*/
const tokenSales = ref<ITokenSale[]>([]);
const tokenSales = useStorageRef<ITokenSale[]>(
[],
STORAGE_KEYS.tokenSales,
);

export const useAeTokenSales = createCustomScopedComposable(() => {
const { activeNetwork, onNetworkChange } = useNetworks();
Expand Down Expand Up @@ -68,7 +72,6 @@ export const useAeTokenSales = createCustomScopedComposable(() => {
));
tokenSales.value = response || [];
} catch (e) {
tokenSales.value = [];
handleUnknownError(e);
}
} else {
Expand Down

0 comments on commit 2c428bd

Please sign in to comment.