Skip to content

Commit 0f39770

Browse files
committed
demo: remove backward compat shim and HMR guards; update imports
- Delete src/lib/Demo.ts compatibility shim - Update imports to use src/lib/demo - Remove hot-reload duplicate-init and route dedupe in demo/index.ts - Keep service-worker update behavior unchanged (non-demo)
1 parent d296810 commit 0f39770

File tree

7 files changed

+9
-62
lines changed

7 files changed

+9
-62
lines changed

src/components/layouts/Sidebar.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,20 @@
185185
<div class="flex-grow"></div>
186186

187187
<AccountMenu
188-
:class="{'active': $route.name === 'root'}"
188+
:class="{'active': $route.name === RouteName.Root}"
189189
@click="navigateTo('/')"/>
190190

191191
<button
192192
class="network reset flex-row"
193-
:class="{'active': $route.name === 'network'}"
193+
:class="{'active': $route.name === RouteName.Network}"
194194
@click="navigateTo('/network')"
195195
>
196196
<ConsensusIcon/>
197197
<span class="label">{{ $t('Network') }}</span>
198198
</button>
199199
<button
200200
class="settings reset flex-row"
201-
:class="{'active': $route.name === 'settings'}"
201+
:class="{'active': $route.name === RouteName.Settings}"
202202
@click="navigateTo('/settings')"
203203
>
204204
<GearIcon/>
@@ -213,7 +213,7 @@ import { defineComponent, ref, computed } from '@vue/composition-api';
213213
import { SwapAsset } from '@nimiq/fastspot-api';
214214
import { GearIcon, Tooltip, InfoCircleIcon } from '@nimiq/vue-components';
215215
import { RouteName, useRouter } from '@/router';
216-
import { checkIfDemoIsActive } from '@/lib/Demo';
216+
import { checkIfDemoIsActive } from '@/lib/demo';
217217
import AnnouncementBox from '../AnnouncementBox.vue';
218218
import AccountMenu from '../AccountMenu.vue';
219219
import PriceChart, { TimeRange } from '../PriceChart.vue';
@@ -384,6 +384,7 @@ export default defineComponent({
384384
385385
return {
386386
CryptoCurrency,
387+
RouteName,
387388
navigateTo,
388389
resetState,
389390
isTestnet,
@@ -401,7 +402,6 @@ export default defineComponent({
401402
updateAvailable,
402403
hideTooltips,
403404
openModal,
404-
RouteName,
405405
SellProvider,
406406
enabledSellProviders,
407407
sellEnabled,

src/components/modals/demos/DemoModalBuy.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import Modal from '@/components/modals/Modal.vue';
6969
import { useAccountStore } from '@/stores/Account';
7070
import { useFiatStore } from '@/stores/Fiat';
7171
import { FIAT_CURRENCIES_OFFERED, CryptoCurrency } from '@/lib/Constants';
72-
import { dangerouslyInsertFakeBuyNimTransaction } from '@/lib/Demo';
72+
import { dangerouslyInsertFakeBuyNimTransaction } from '@/lib/demo';
7373
import { useRouter } from '@/router';
7474
import BankIconButton from '@/components/BankIconButton.vue';
7575
import { useAddressStore } from '@/stores/Address';

src/hub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { PlainTransactionDetails } from '@nimiq/core';
1818
import type { RequestBehavior, BehaviorType } from '@nimiq/hub-api/dist/src/RequestBehavior.d';
1919
import type { ForwardRequest } from '@opengsn/common/dist/EIP712/ForwardRequest';
2020
import Config from 'config';
21-
import { DemoHubApi, checkIfDemoIsActive } from '@/lib/Demo';
21+
import { DemoHubApi, checkIfDemoIsActive } from '@/lib/demo';
2222
import { useAccountStore, AccountInfo, AccountType } from './stores/Account';
2323
import { useAddressStore, AddressInfo, AddressType } from './stores/Address';
2424
import { useBtcAddressStore, BtcAddressInfo } from './stores/BtcAddress';

src/lib/Demo.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/lib/demo/index.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ let demoRouter: VueRouter;
5252
// Simple state tracking for current modal
5353
let currentModal: DemoFlowType = 'idle';
5454

55-
// Track if demo has been initialized to prevent duplicate initialization
56-
let isInitialized = false;
5755

5856
// Demo modal imports for dynamic loading
5957
const DemoFallbackModal = () =>
@@ -78,12 +76,6 @@ export function dangerouslyInitializeDemo(router: VueRouter): void {
7876
return;
7977
}
8078

81-
// Prevent duplicate initialization during hot reload
82-
if (isInitialized && demoRouter === router) {
83-
console.debug('[Demo] Demo already initialized, skipping duplicate initialization.');
84-
return;
85-
}
86-
8779
console.warn('[Demo] Initializing demo environment...');
8880

8981
demoRouter = router;
@@ -114,8 +106,6 @@ export function dangerouslyInitializeDemo(router: VueRouter): void {
114106
// Send initial ready message to parent frame
115107
sendInitialReadyMessage();
116108

117-
// Mark as initialized
118-
isInitialized = true;
119109
}
120110

121111
/**
@@ -148,12 +138,6 @@ function sendInitialReadyMessage(): void {
148138
* Adds routes pointing to our demo modals.
149139
*/
150140
function addDemoModalRoutes(): void {
151-
// Use a flag attached to the router instance to track if routes were added
152-
// This persists across hot reloads since the router instance persists
153-
if ((demoRouter as any)._demoRoutesAdded) {
154-
console.debug('[Demo] Routes already added to router, skipping duplicate registration');
155-
return;
156-
}
157141

158142
// Import layout components for explicit inclusion
159143
const AccountOverview = () => import(/* webpackChunkName: "account-overview" */ '@/components/layouts/AccountOverview.vue');
@@ -184,8 +168,6 @@ function addDemoModalRoutes(): void {
184168
meta: { column: Columns.DYNAMIC },
185169
});
186170

187-
// Mark routes as added on the router instance
188-
(demoRouter as any)._demoRoutesAdded = true;
189171
console.debug('[Demo] Demo routes added successfully');
190172
}
191173

src/main-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { init as initFastspotApi } from '@nimiq/fastspot-api';
88
import VuePortal from '@linusborg/vue-simple-portal';
99

1010
import App from './App.vue';
11-
import { dangerouslyInitializeDemo } from './lib/Demo';
11+
import { dangerouslyInitializeDemo } from './lib/demo';
1212
import { useAccountStore } from './stores/Account';
1313
import { useFiatStore } from './stores/Fiat';
1414
import { useSettingsStore } from './stores/Settings';

src/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ref, watch } from '@vue/composition-api';
33
import { SignedTransaction } from '@nimiq/hub-api';
44
import type { Client, PlainStakingContract, PlainTransactionDetails } from '@nimiq/core';
55

6-
import { checkIfDemoIsActive } from '@/lib/Demo';
6+
import { checkIfDemoIsActive } from '@/lib/demo';
77
import { useAddressStore } from './stores/Address';
88
import { useTransactionsStore, TransactionState } from './stores/Transactions';
99
import { useNetworkStore } from './stores/Network';

0 commit comments

Comments
 (0)