@@ -125,25 +125,25 @@ function insertCustomDemoStyles() {
125
125
* Sets up a router guard to handle redirects for the demo environment.
126
126
*/
127
127
function rewriteDemoRoutes ( ) {
128
- demoRouter . beforeEach ( ( to , _from , next ) => {
128
+ demoRouter . beforeResolve ( async ( to , from , next ) => {
129
+ // Avoid displaying receive modal
129
130
if ( to . path . startsWith ( '/receive/' ) && ! to . path . startsWith ( '/receive/nim' ) ) {
130
- return next ( {
131
- path : `/${ DemoModal . Fallback } ` ,
132
- query : { ...to . query , [ DEMO_PARAM ] : '' } ,
133
- } )
131
+ return next ( { path : `/${ DemoModal . Fallback } ` , query : { ...to . query , [ DEMO_PARAM ] : '' } } ) ;
134
132
}
133
+
135
134
// Redirect certain known paths to the Buy demo modal
136
135
if ( to . path === '/buy' ) {
137
- return next ( {
138
- path : `/${ DemoModal . Buy } ` ,
139
- query : { ...to . query , [ DEMO_PARAM ] : '' } ,
140
- } ) ;
136
+ return next ( { path : `/${ DemoModal . Buy } ` , query : { ...to . query , [ DEMO_PARAM ] : '' } , replace : true } ) ;
141
137
}
142
138
143
- // Ensure the ?demo param is in place
144
- if ( to . query . demo === '' ) return next ( ) ;
145
- return next ( { path : to . path , query : { ...to . query , [ DEMO_PARAM ] : '' } } ) ;
139
+ // FIXME: When clicking the hamburger menu, nothing opens
140
+ if ( to . query [ DEMO_PARAM ] === undefined ) {
141
+ next ( { path : to . path , query : { ...to . query , [ DEMO_PARAM ] : '' } , replace : true } ) ;
142
+ }
143
+
144
+ next ( ) ;
146
145
} ) ;
146
+
147
147
}
148
148
149
149
/**
@@ -1945,29 +1945,29 @@ function observeReceiveModal(processedElements: WeakSet<Element>) {
1945
1945
// Find the receive modal
1946
1946
const receiveModal = document . querySelector ( '.receive-modal' ) ;
1947
1947
if ( ! receiveModal ) return ;
1948
-
1948
+
1949
1949
// Look for buttons that should redirect to the fallback modal
1950
1950
const buttons = receiveModal . querySelectorAll ( '.nq-button-s, .qr-button' ) ;
1951
-
1951
+
1952
1952
buttons . forEach ( button => {
1953
1953
// Skip if we've already processed this button
1954
1954
if ( processedElements . has ( button ) ) return ;
1955
-
1955
+
1956
1956
// Mark as processed to avoid adding multiple listeners
1957
1957
processedElements . add ( button ) ;
1958
-
1958
+
1959
1959
// Replace the original click handler with our redirect
1960
1960
button . addEventListener ( 'click' , ( event ) => {
1961
1961
// Prevent the default action and stop propagation
1962
1962
event . preventDefault ( ) ;
1963
1963
event . stopPropagation ( ) ;
1964
-
1964
+
1965
1965
// Redirect to the fallback modal
1966
1966
demoRouter . replace ( {
1967
1967
path : `/${ DemoModal . Fallback } ` ,
1968
1968
query : { [ DEMO_PARAM ] : '' } ,
1969
1969
} ) ;
1970
-
1970
+
1971
1971
console . log ( '[Demo] Redirected receive modal button click to fallback modal' ) ;
1972
1972
} , true ) ; // Use capture to intercept the event before other handlers
1973
1973
} ) ;
0 commit comments