Skip to content

Commit ed6d7c1

Browse files
committed
fix: store the current state of the ListCard in localStorage
1 parent a8ce36c commit ed6d7c1

File tree

8 files changed

+17
-8
lines changed

8 files changed

+17
-8
lines changed

packages/dapp-svelte-wallet/ui/lib/ListCard.svelte

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
// true iff new items should start expanded
1515
export let expandDefault = false;
1616
17-
let expandState = [];
17+
export let storeKey = '';
18+
19+
let expandState = storeKey ? JSON.parse(localStorage.getItem(`ListCard.${storeKey}`) || '[]') : [];
1820
1921
$: isExpanded = id => expandState.includes(id) !== expandDefault;
2022
@@ -25,6 +27,9 @@
2527
} else {
2628
expandState = [...expandState, id];
2729
}
30+
if (storeKey) {
31+
localStorage.setItem(`ListCard.${storeKey}`, JSON.stringify(expandState));
32+
}
2833
};
2934
</script>
3035

packages/dapp-svelte-wallet/ui/src/Contacts.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { contacts, walletP } from './store';
1010
</script>
1111

12-
<ListCard items={$contacts}>
12+
<ListCard storeKey="contacts" items={$contacts}>
1313
<div slot="title">
1414
<Card.Title
1515
title="Contacts"

packages/dapp-svelte-wallet/ui/src/Dapps.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export let expandDefault = true;
99
</script>
1010

11-
<ListCard items={$dapps} expandDefault={expandDefault}>
11+
<ListCard items={$dapps} storeKey="dapps-{expandDefault}" {expandDefault}>
1212
<div slot="title">
1313
<Card.Title title="Dapps" />
1414
</div>

packages/dapp-svelte-wallet/ui/src/Issuers.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { issuers, walletP } from './store';
1010
</script>
1111

12-
<ListCard items={$issuers}>
12+
<ListCard items={$issuers} storeKey="issuers">
1313
<div slot="title">
1414
<Card.Title
1515
title="Issuers"

packages/dapp-svelte-wallet/ui/src/Payments.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Card from "smelte/src/components/Card";
1010
$: paymentItems = $payments.filter(pmt => pmt.status !== 'deposited');
1111
</script>
1212

13-
<ListCard items={paymentItems} expandDefault={true}>
13+
<ListCard items={paymentItems} storeKey="payments.true" expandDefault={true}>
1414
<div slot="title">
1515
<Card.Title title="Incoming Payments" />
1616
</div>

packages/dapp-svelte-wallet/ui/src/Purses.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { purses } from './store';
77
</script>
88

9-
<ListCard items={$purses}>
9+
<ListCard items={$purses} storeKey="purses">
1010
<div slot="title">
1111
<Card.Title title="Purses" />
1212
</div>

packages/dapp-svelte-wallet/ui/src/Transactions.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
</script>
88

99
<!-- filter out the history -->
10-
<ListCard items={($inbox || []).filter(({ status }) => status === undefined || status === 'pending')} expandDefault={true}>
10+
<ListCard
11+
items={($inbox || []).filter(({ status }) => status === undefined || status === 'pending')}
12+
storeKey="inbox"
13+
expandDefault={true}
14+
>
1115
<div slot="title">
1216
<Card.Title title="Offers" />
1317
</div>

packages/dapp-svelte-wallet/ui/src/captp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function makeCapTPConnection(makeConnection, { onReset }) {
2222
// Throw away our state.
2323
bootPK = makePromiseKit();
2424
onReset(bootPK.promise.then(_ => true));
25-
abort();
25+
abort && abort();
2626
}
2727

2828
// Stable identity for the connection handler.

0 commit comments

Comments
 (0)