Skip to content

Commit 23df5fa

Browse files
Merge pull request #179 from Geode-solutions/fix/refactor_watches
fix(watches): stores props
2 parents 869dbd4 + 139eae9 commit 23df5fa

File tree

5 files changed

+55
-42
lines changed

5 files changed

+55
-42
lines changed

components/Launcher.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<v-container class="justify">
33
<v-row align-content="center" align="center">
44
<v-col
5-
v-if="!is_captcha_validated"
5+
v-if="!infra_store.is_captcha_validated"
66
class="align"
77
cols="12"
88
align-self="center"
@@ -21,16 +21,21 @@
2121
<script setup>
2222
import Status from "@/utils/status.js"
2323
24-
const viewer_store = use_viewer_store()
2524
const infra_store = use_infra_store()
26-
const { is_captcha_validated } = storeToRefs(infra_store)
27-
2825
const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY
2926
30-
watch(is_captcha_validated, async (value) => {
31-
if (value === true && process.client) {
32-
await infra_store.create_backend()
33-
await viewer_store.ws_connect()
27+
watch(
28+
() => infra_store.is_captcha_validated,
29+
(value, oldValue) => {
30+
if (value && !oldValue && process.client) {
31+
infra_store.create_backend()
32+
}
33+
},
34+
)
35+
36+
onMounted(() => {
37+
if (infra_store.is_captcha_validated) {
38+
infra_store.create_backend()
3439
}
3540
})
3641
</script>

components/Loading.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<v-col cols="12" class="ma-3">
44
<v-card loading>
55
<v-card-title class="text-center">
6-
Cloud instance is starting...
6+
Microservices are starting...
77
</v-card-title>
88
<v-card-subtitle class="text-center">
99
Why do you have to wait?
1010
</v-card-subtitle>
1111
<v-card-text class="text-center">
12-
We start our server only on demand... and this takes a few minutes
13-
before you can use our free app.
12+
We start our microservices only on demand... and this takes a few
13+
minutes before you can use our free app.
1414
<br />
1515
This is aligned with our energy sobriety policy. So be patient
1616
<v-icon color="primary" size="20">

components/PackagesVersions.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@
5252
await Promise.all(array_promise)
5353
}
5454
55-
watch(geode_store.status, (value) => {
56-
if (value == Status.CONNECTED) get_packages_versions()
57-
})
55+
watch(
56+
() => geode_store.status,
57+
(value) => {
58+
if (value == Status.CONNECTED) get_packages_versions()
59+
},
60+
)
5861
5962
await get_packages_versions()
6063
</script>

components/Recaptcha.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<ClientOnly>
33
<vue-recaptcha
44
ref="recaptcha"
5-
:sitekey="site_key"
5+
:sitekey="props.site_key"
66
:load-recaptcha-script="true"
77
align-self="center"
8-
@expired="is_captcha_validated = false"
8+
@expired="infra_store.is_captcha_validated = false"
99
@verify="submit_recaptcha"
1010
/>
1111
</ClientOnly>
@@ -14,12 +14,10 @@
1414
<script setup>
1515
import { VueRecaptcha } from "vue-recaptcha"
1616
const infra_store = use_infra_store()
17-
const { is_captcha_validated } = storeToRefs(infra_store)
1817
1918
const props = defineProps({
2019
site_key: { type: String, required: true },
2120
})
22-
const { site_key } = props
2321
2422
onMounted(() => {
2523
if (process.client) {

components/RemoteRenderingView.vue

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"
1515
class="pa-0"
1616
@click="get_x_y"
17-
@keydown.esc="app_store.toggle_picking_mode(false)"
17+
@keydown.esc="viewer_store.toggle_picking_mode(false)"
1818
/>
1919
</div>
2020
</ClientOnly>
@@ -26,8 +26,12 @@
2626
import viewer_schemas from "@geode/opengeodeweb-viewer/schemas.json"
2727
import Status from "@/utils/status.js"
2828
29+
const props = defineProps({
30+
viewId: { type: String, default: "-1" },
31+
})
32+
2933
const viewer_store = use_viewer_store()
30-
const viewer = ref(null)
34+
const viewer = useTemplateRef("viewer")
3135
const { width, height } = useElementSize(viewer)
3236
3337
const { width: windowWidth, height: windowHeight } = useWindowSize()
@@ -43,13 +47,7 @@
4347
}
4448
}
4549
46-
const props = defineProps({
47-
viewId: { type: String, default: "-1" },
48-
})
49-
50-
const { viewId } = toRefs(props)
5150
const connected = ref(false)
52-
5351
const view = vtkRemoteView.newInstance({
5452
rpcWheelEvent: "viewport.mouse.zoom.wheel",
5553
})
@@ -69,33 +67,42 @@
6967
resize()
7068
})
7169
72-
watch(viewer_store.picking_mode, (value) => {
73-
const cursor = value ? "crosshair" : "pointer"
74-
view.getCanvasView().setCursor(cursor)
75-
})
70+
watch(
71+
() => viewer_store.picking_mode,
72+
(value) => {
73+
const cursor = value ? "crosshair" : "pointer"
74+
view.getCanvasView().setCursor(cursor)
75+
},
76+
)
7677
7778
watch([width, height], () => {
7879
resize()
7980
})
8081
81-
watch(viewer_store.client, () => {
82-
connect()
83-
})
84-
85-
watch(viewId, (id) => {
86-
if (connected.value) {
87-
view.setViewId(id)
88-
view.render()
89-
}
90-
})
82+
watch(
83+
() => viewer_store.client,
84+
() => {
85+
connect()
86+
},
87+
)
88+
89+
watch(
90+
() => props.viewId,
91+
(id) => {
92+
if (connected.value) {
93+
view.setViewId(id)
94+
view.render()
95+
}
96+
},
97+
)
9198
9299
function connect() {
93-
if (!viewer_store.status !== Status.CONNECTED) {
100+
if (viewer_store.status !== Status.CONNECTED) {
94101
return
95102
}
96103
const session = viewer_store.client.value.getConnection().getSession()
97104
view.setSession(session)
98-
view.setViewId(viewId.value)
105+
view.setViewId(props.viewId)
99106
connected.value = true
100107
view.render()
101108
}

0 commit comments

Comments
 (0)