Skip to content

Commit 8664f66

Browse files
committed
feat: dont refresh page after wallet reset on web
1 parent d370a9d commit 8664f66

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/composables/permissions.ts

+5
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,17 @@ export function usePermissions() {
207207
}
208208
}
209209

210+
function resetPermissions() {
211+
permissions.value = {};
212+
}
213+
210214
return {
211215
permissions,
212216
addPermission,
213217
removePermission,
214218
checkPermission,
215219
checkOrAskPermission,
216220
checkTransactionSignLimit,
221+
resetPermissions,
217222
};
218223
}

src/composables/transactionList.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function useTransactionList({
8383
...transactionsLoaded.value,
8484
]);
8585

86-
function resetState() {
86+
function resetTransactionListState() {
8787
state.value = {
8888
accountAddress,
8989
assetContractId,
@@ -148,7 +148,7 @@ export function useTransactionList({
148148
async function initializeTransactionListPolling() {
149149
if (!state.value.isInitialLoadDone || !transactionsLoaded.value.length) {
150150
if (state.value.isInitialLoadDone && !transactionsLoaded.value.length) {
151-
resetState();
151+
resetTransactionListState();
152152
}
153153
await loadCurrentPageTransactions();
154154
if (
@@ -208,7 +208,7 @@ export function useTransactionList({
208208
|| state.value.assetContractId !== assetContractId
209209
|| state.value.networkName !== activeNetwork.value.name
210210
) {
211-
resetState();
211+
resetTransactionListState();
212212
}
213213

214214
return {
@@ -220,5 +220,6 @@ export function useTransactionList({
220220
loadCurrentPageTransactions,
221221
initializeTransactionListPolling,
222222
stopTransactionListPolling,
223+
resetTransactionListState,
223224
};
224225
}

src/popup/components/Modals/ResetWalletModal.vue

+13-2
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@
5959
import { defineComponent, PropType } from 'vue';
6060
import { useRouter } from 'vue-router';
6161
import type { RejectCallback, ResolveCallback } from '@/types';
62+
import { IS_MOBILE_APP, PROTOCOLS } from '@/constants';
6263
import {
6364
useAccounts,
6465
useAeSdk,
6566
useNetworks,
67+
usePermissions,
68+
useTransactionList,
6669
useUi,
6770
} from '@/composables';
68-
import { IS_MOBILE_APP } from '@/constants';
6971
import { ROUTE_INDEX } from '@/popup/router/routeNames';
7072
import { WalletStorage } from '@/lib/WalletStorage';
7173
import { SecureMobileStorage } from '@/lib/SecureMobileStorage';
@@ -93,23 +95,32 @@ export default defineComponent({
9395
const { resetNetworks } = useNetworks();
9496
const { resetUiSettings } = useUi();
9597
const { disconnectDapps } = useAeSdk();
98+
const { resetPermissions } = usePermissions();
99+
100+
const { resetTransactionListState } = useTransactionList({
101+
protocol: PROTOCOLS.aeternity,
102+
accountAddress: null as any, // `any` use deliberately to force setting empty state
103+
});
96104
97105
async function onReset() {
98106
resetAccounts();
99107
resetNetworks();
100108
resetUiSettings();
101109
disconnectDapps();
110+
resetTransactionListState();
111+
resetPermissions();
102112
103113
WalletStorage.clear();
104114
if (IS_MOBILE_APP) {
105115
SecureMobileStorage.clear();
106116
}
117+
107118
// TODO: Rethink this approach
108119
// It is removing the remaining vuex state
109120
await browser.storage.local.clear();
110121
await router.push({ name: ROUTE_INDEX });
122+
111123
props.resolve();
112-
window.location.reload();
113124
}
114125
115126
return {

0 commit comments

Comments
 (0)