Skip to content

Commit

Permalink
fix: inscriptions cache bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo authored and kyranjamie committed Jun 7, 2023
1 parent 11ce4b0 commit 3c67a9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/app/common/hooks/use-key-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { InternalMethods } from '@shared/message-types';
import { sendMessage } from '@shared/messages';
import { clearChromeStorage } from '@shared/storage';

import { queryClient } from '@app/common/persistence';
import { partiallyClearLocalStorage } from '@app/common/store-utils';
import { useAppDispatch } from '@app/store';
import { createNewAccount, stxChainActions } from '@app/store/chains/stx-chain.actions';
Expand Down Expand Up @@ -61,6 +62,7 @@ export function useKeyActions() {
await clearChromeStorage();
partiallyClearLocalStorage();
void analytics.track('sign_out');
queryClient.clear();
},

lockWallet() {
Expand Down
9 changes: 5 additions & 4 deletions src/app/query/bitcoin/ordinals/use-inscriptions.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ensureArray } from '@shared/utils';

import { createNumArrayOfRange } from '@app/common/utils';
import { QueryPrefixes } from '@app/query/query-prefixes';
import { useCurrentAccountIndex } from '@app/store/accounts/account';
import { useCurrentAccountNativeSegwitIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
import { useTaprootCurrentAccountPrivateKeychain } from '@app/store/accounts/blockchain/bitcoin/taproot-account.hooks';
import { useCurrentNetwork } from '@app/store/networks/networks.selectors';

Expand Down Expand Up @@ -50,7 +50,8 @@ async function fetchInscriptions(addresses: string | string[], offset = 0, limit
export function useTaprootInscriptionsInfiniteQuery() {
const network = useCurrentNetwork();
const keychain = useTaprootCurrentAccountPrivateKeychain();
const currentAccountIndex = useCurrentAccountIndex();
const nativeSegwitSigner = useCurrentAccountNativeSegwitIndexZeroSigner();
const currentBitcoinAddress = nativeSegwitSigner.address;

const defaultAccountData = {
fromIndex: 0,
Expand All @@ -62,7 +63,7 @@ export function useTaprootInscriptionsInfiniteQuery() {
useEffect(() => {
currentAccData.current = defaultAccountData;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentAccountIndex]);
}, [currentBitcoinAddress]);

function getTaprootAddressData(fromIndex: number, toIndex: number) {
return createNumArrayOfRange(fromIndex, toIndex - 1).reduce(
Expand All @@ -80,7 +81,7 @@ export function useTaprootInscriptionsInfiniteQuery() {
}

const query = useInfiniteQuery({
queryKey: [QueryPrefixes.InscriptionsFromApiInfiniteQuery, currentAccountIndex, network.id],
queryKey: [QueryPrefixes.InscriptionsFromApiInfiniteQuery, currentBitcoinAddress, network.id],
async queryFn({ pageParam }) {
const responsesArr: InscriptionsQueryResponse[] = [];
let addressesData = getTaprootAddressData(
Expand Down

0 comments on commit 3c67a9b

Please sign in to comment.