Skip to content

Commit

Permalink
clearLocalStorage function
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestarrdev committed Jun 27, 2023
1 parent c19757c commit 14f4c25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/TransactionsTab/TransactionsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
ClearTransactionsButton,
} from "./TransactionsTab.styles";
import AnimatedWalletTransaction from "./subcomponents/AnimatedWalletTransaction/AnimatedWalletTransaction";
import { clearLocalStorage } from "./helpers/clearLocalStorage";

type TransactionsTabType = {
address: string;
Expand Down Expand Up @@ -159,6 +160,7 @@ const TransactionsTab = ({

const handleClearTransactions = () => {
dispatch(setTransactions(null));
clearLocalStorage('airswap/transactions')
};

return (
Expand Down
8 changes: 8 additions & 0 deletions src/components/TransactionsTab/helpers/clearLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const clearLocalStorage = (prefix: string) => {
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key?.startsWith(prefix)) {
localStorage.removeItem(key)
}
}
}

0 comments on commit 14f4c25

Please sign in to comment.