@@ -36,6 +36,7 @@ const props = defineProps({
3636 show: Boolean ,
3737})
3838
39+ let bc
3940onMounted (async () => {
4041 await init ()
4142 initConfig ()
@@ -44,6 +45,20 @@ onMounted(async () => {
4445
4546 nodeStore .settings .network = networks[selectedNetwork .value ]
4647
48+ bc = new BroadcastChannel (" node" )
49+ bc .postMessage (" ping" )
50+ bc .onmessage = (e ) => {
51+ if (e .data === " ping" && status .value === StatusMap .Started ) {
52+ bc .postMessage (" running" )
53+ }
54+ if (e .data === " running" ) {
55+ disableStart .value = true
56+ }
57+ if (e .data === " start" && status .value === StatusMap .Initialized ) {
58+ disableStart .value = true
59+ }
60+ }
61+
4762 /** autostart */
4863 if (nodeStore .settings .autostart ) {
4964 const delayedStart = setTimeout (() => {
@@ -109,6 +124,7 @@ onMounted(async () => {
109124 }
110125})
111126
127+ const disableStart = ref (false )
112128const status = computed (() => nodeStore .status )
113129
114130const networks = [" Mainnet" , " Arabica" , " Mocha" ]
@@ -292,7 +308,12 @@ const syncingPercentage = (ranges) => {
292308const handleStop = () => {
293309 location .reload ()
294310}
311+
295312const handleStart = async () => {
313+ if (disableStart .value ) return
314+
315+ bc .postMessage (" start" )
316+
296317 nodeStore .status = StatusMap .Starting
297318 amp .log (" sampling:start" , { network: networks[selectedNetwork .value ], mobile: isMobile () })
298319
@@ -544,7 +565,12 @@ watch(
544565
545566 <Flex direction =" column" gap =" 12" >
546567 <Flex direction =" column" gap =" 4" :class =" $style.secondary_card" >
547- <Flex @click =" showDetails = !showDetails" align =" center" justify =" between" :class =" $style.header" >
568+ <Flex
569+ @click =" showDetails = !showDetails"
570+ align =" center"
571+ justify =" between"
572+ :class =" [$style.header, status !== StatusMap.Started && $style.disabled]"
573+ >
548574 <Text size =" 12" weight =" 600" color =" secondary" >Details</Text >
549575 <Icon
550576 name =" chevron"
@@ -687,14 +713,14 @@ watch(
687713 type =" secondary"
688714 size =" small"
689715 wide
690- :disabled =" [StatusMap.Starting, StatusMap.Started].includes(status) || !nodeStore.bootnodes.length"
716+ :disabled =" [StatusMap.Starting, StatusMap.Started].includes(status) || !nodeStore.bootnodes.length || disableStart "
691717 >
692718 <Icon v-if =" status === StatusMap.Started" name =" zap-circle" size =" 12" color =" brand" />
693- {{
694- status === StatusMap.Started
695- ? ` Running data availability sampling for ${ networks[selectedNetwork]}`
696- : "Start Sampling"
697- }}
719+ < template v-if = " disableStart " > Node is already running in other tab </ template >
720+ < template v-else-if = " status === StatusMap .Started " >
721+ Running data availability sampling for {{ networks[selectedNetwork] }}
722+ </ template >
723+ < template v-else > Start Sampling </ template >
698724 </Button >
699725
700726 <Tooltip v-if =" status === StatusMap.Started" wide >
@@ -711,7 +737,9 @@ watch(
711737 <Flex align =" center" direction =" column" gap =" 4" >
712738 <Text size =" 11" weight =" 500" color =" tertiary" >
713739 Read more about the light node on our
714- <a href =" https://docs.celenium.io" target =" _blank" style =" color : var (--txt-secondary )" >docs</a >.
740+ <a href =" https://docs.celenium.io/features/light-node" target =" _blank" style =" color : var (--txt-secondary )"
741+ >docs</a
742+ >.
715743 </Text >
716744 <Text size =" 11" weight =" 500" color =" tertiary" >
717745 Powered by <a href =" https://lumina.rs" target =" _blank" style =" color : var (--txt-secondary )" >Lumina.rs</a >
0 commit comments