Skip to content

Commit 3b8285e

Browse files
pull from next branch
1 parent afa072a commit 3b8285e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

stores/cloud.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { defineStore } from 'pinia'
2+
import { useStorage } from '@vueuse/core'
23

34
export const use_cloud_store = defineStore('cloud', {
45
state: () => ({
5-
ID: '',
6+
ID: useStorage('ID', ''),
67
is_captcha_validated: false,
78
is_cloud_running: false,
89
is_connexion_launched: false,
@@ -25,19 +26,28 @@ export const use_cloud_store = defineStore('cloud', {
2526
viewer_url = viewer_url + '/ws'
2627
return viewer_url
2728
},
29+
is_cloud_running: (state) => {
30+
const geode_store = use_geode_store()
31+
const websocket_store = use_websocket_store()
32+
return state.is_cloud_running
33+
},
34+
is_cloud_busy: () => {
35+
const geode_store = use_geode_store()
36+
const websocket_store = use_websocket_store()
37+
return geode_store.api_busy() && websocket_store.websocket_busy()
38+
}
39+
2840
},
2941
actions: {
3042
async create_connexion () {
3143
if (this.is_connexion_launched) { return }
3244
this.is_connexion_launched = true
33-
const ID = localStorage.getItem('ID')
34-
if (ID === null || typeof ID === 'undefined') {
45+
if (this.ID === '' || this.ID === null || typeof this.ID === 'undefined') {
3546
return this.create_backend()
3647
} else {
3748
const { data, error } = await useFetch(`${this.geode_url}/ping`, { method: 'POST' })
3849
console.log("error", error)
3950
if (data.value !== null) {
40-
this.ID = ID
4151
this.is_cloud_running = true
4252
return this.ping_task()
4353
} else {
@@ -60,6 +70,7 @@ export const use_cloud_store = defineStore('cloud', {
6070
errors_store.server_error = true
6171
}
6272
},
73+
6374
ping_task () {
6475
setInterval(() => this.do_ping(), 10 * 1000)
6576
},

0 commit comments

Comments
 (0)