Skip to content

Commit 44874fe

Browse files
committed
upd lumina modal
1 parent 0178512 commit 44874fe

2 files changed

Lines changed: 52 additions & 15 deletions

File tree

components/modals/LightNodeModal.vue

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const props = defineProps({
3636
show: Boolean,
3737
})
3838
39+
let bc
3940
onMounted(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)
112128
const status = computed(() => nodeStore.status)
113129
114130
const networks = ["Mainnet", "Arabica", "Mocha"]
@@ -292,7 +308,12 @@ const syncingPercentage = (ranges) => {
292308
const handleStop = () => {
293309
location.reload()
294310
}
311+
295312
const 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>

components/modals/LightNodeSettingsModal.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const resizeTextarea = () => {
5656
const handleTextareaKeyup = (e) => {
5757
e.stopPropagation()
5858
resizeTextarea()
59-
if (!/^[a-z0-9]+$/i.test(e.key) || e.key.length !== 1) return
59+
if (!/^[а-яa-z0-9]+$/i.test(e.key) || e.key.length !== 1) return
6060
6161
const newBootnodes = bootnodesTerm.value.split("\n").filter((b) => b.length)
6262
newBootnodes.forEach((b) => {
@@ -99,15 +99,24 @@ const handleDeleteIndexDBStore = (name) => {
9999
})
100100
}
101101
102+
const updateBootnodes = async () => {
103+
bootnodesTerm.value = nodeStore.bootnodes.join("\n")
104+
await nextTick()
105+
resizeTextarea()
106+
}
107+
108+
watch(
109+
() => nodeStore.settings.network,
110+
() => {
111+
if (props.show) updateBootnodes()
112+
},
113+
)
114+
102115
watch(
103116
() => props.show,
104117
async () => {
105118
if (props.show) {
106-
bootnodesTerm.value = nodeStore.bootnodes.join("\n")
107-
108-
await nextTick()
109-
110-
resizeTextarea()
119+
updateBootnodes()
111120
}
112121
},
113122
)
@@ -121,7 +130,7 @@ watch(
121130
<Flex direction="column" gap="16">
122131
<Flex justify="between">
123132
<Flex direction="column" gap="6">
124-
<Text size="13" weight="600" color="primary">Light node autostart</Text>
133+
<Text size="13" weight="600" color="primary">Autostart</Text>
125134
<Text size="12" weight="500" color="tertiary"> Automatically launch a node every time you visit the Celenium </Text>
126135
</Flex>
127136

0 commit comments

Comments
 (0)