Skip to content

Commit

Permalink
fix: reset chat stores on wallet change (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght authored Jul 4, 2024
1 parent 0ac43d4 commit 91efac4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/components/button/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@/components/ui/popover';
import { useGetAllWalletsQuery } from '@/graphql/queries/__generated__/wallet.generated';
import { cn } from '@/lib/utils';
import { useChat, useContactStore } from '@/stores/contacts';
import { LOCALSTORAGE_KEYS } from '@/utils/constants';
import { ROUTES } from '@/utils/routes';

Expand All @@ -29,6 +30,9 @@ import { RefreshWallet } from './RefreshWallet';
export function WalletButton() {
const [open, setOpen] = useState(false);

const setCurrentContact = useContactStore(s => s.setCurrentContact);
const setCurrentPaymentOption = useChat(s => s.setCurrentPaymentOption);

const { push } = useRouter();

const { data, error } = useGetAllWalletsQuery();
Expand Down Expand Up @@ -92,6 +96,8 @@ export function WalletButton() {
setValue(currentValue);
push(ROUTES.app.home);
setOpen(false);
setCurrentContact(undefined);
setCurrentPaymentOption(undefined);
}}
>
{w.label}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ type Contact = {

type ContactState = {
currentContact: Contact | undefined;
setCurrentContact: (contact: Contact) => void;
setCurrentContact: (contact: Contact | undefined) => void;
};

export const useContactStore = create<ContactState>()(set => ({
currentContact: undefined,
setCurrentContact: (contact: Contact) => set({ currentContact: contact }),
setCurrentContact: contact => set({ currentContact: contact }),
}));

export type PaymentOption = {
Expand Down

0 comments on commit 91efac4

Please sign in to comment.