|
10 | 10 | import utxoManagement from 'src/components/settings/utxoManagement.vue' |
11 | 11 | import sweepPrivateKey from 'src/components/settings/sweepPrivateKey.vue' |
12 | 12 | import hdAddressesView from 'src/components/settings/hdAddresses.vue' |
13 | | - import { ref, computed, watch } from 'vue' |
| 13 | + import { defineComponent, ref, computed, watch } from 'vue' |
14 | 14 | import { storeToRefs } from 'pinia' |
15 | 15 | import { DefaultProvider } from 'mainnet-js' |
16 | 16 | import { waitForInitialized } from 'src/utils/utils' |
|
37 | 37 |
|
38 | 38 | DefaultProvider.servers.chipnet = ["wss://chipnet.bch.ninja:50004"]; |
39 | 39 |
|
40 | | - // The currentView and its viewSpecificProps are computed based on 'store.displayView' |
41 | | - // These view & prop refs are passed to a dynamic component rendering the current view |
42 | | - // This way views can be wrapped with KeepAlive to preserve its state across view changes |
43 | | - // Excluding the settingsMenu bc we want to rerender it when navigating to it |
| 40 | + // The currentView and its viewSpecificProps are computed based on 'store.displayView' |
| 41 | + // and passed to a dynamic component wrapped in KeepAlive to preserve state. |
| 42 | + // KeepAlive stays mounted permanently so the views are cached regardless of navigation. |
| 43 | + // Settings View re-renders on navigation, a placeholder component used for the KeepAlive |
| 44 | + const emptyView = defineComponent({ render: () => null }) |
44 | 45 | const currentView = computed(() => { |
45 | 46 | switch (store.displayView) { |
46 | 47 | case 1: return bchWalletView; |
47 | 48 | case 2: return myTokensView; |
48 | 49 | case 3: return historyView; |
49 | 50 | case 4: return connectDappView; |
| 51 | + case 5: return emptyView; |
50 | 52 | case 6: return createTokensView; |
51 | 53 | case 7: return utxoManagement; |
52 | 54 | case 8: return sweepPrivateKey; |
|
196 | 198 | </nav> |
197 | 199 | </header> |
198 | 200 | <main style="margin: 20px auto; max-width: 78rem;"> |
199 | | - <KeepAlive v-if="store.displayView != 5"> |
| 201 | + <KeepAlive> |
200 | 202 | <component :is="currentView" v-bind="viewSpecificProps"/> |
201 | 203 | </KeepAlive> |
202 | 204 | <settingsMenu v-if="store.displayView == 5" /> |
|
0 commit comments