From 6a16327c30a68d0b557c311073270c5de91dd0af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?=
<45078678+oguzhankoral@users.noreply.github.com>
Date: Tue, 20 Feb 2024 23:54:15 +0300
Subject: [PATCH] Fix (Cache): CNX-8976 bug on initialization on clear setup
(#323)
* Call sketchup functions before mount
* Change default to app.speckle.systems
* Use account id instead uuid to get selected account before
---
ui/src/App.vue | 33 ++++++++++++++++-----------------
ui/src/vue-apollo.js | 6 +++---
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/ui/src/App.vue b/ui/src/App.vue
index 912e621..2a34843 100644
--- a/ui/src/App.vue
+++ b/ui/src/App.vue
@@ -104,12 +104,12 @@
/>
-
+
@@ -149,16 +149,16 @@ global.collectVersions = function (versions) {
global.loadAccounts = function (accounts) {
console.log('>>> SpeckleSketchup: Loading accounts', accounts)
localStorage.setItem('localAccounts', JSON.stringify(accounts))
- let uuid = localStorage.getItem('uuid')
+ let selectedAccountId = localStorage.getItem('selectedAccountId')
if (accounts.length !== 0){
- if (uuid) {
- var account = accounts.find((acct) => acct['userInfo']['id'] === uuid)
+ if (selectedAccountId) {
+ var account = accounts.find((acct) => acct['id'] === selectedAccountId)
if (account){
global.setSelectedAccount(account)
return
}
- global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
+ global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
}
@@ -166,7 +166,7 @@ global.setSelectedAccount = function (account) {
localStorage.setItem('selectedAccount', JSON.stringify(account))
localStorage.setItem('serverUrl', account['serverInfo']['url'])
localStorage.setItem('SpeckleSketchup.AuthToken', account['token'])
- localStorage.setItem('uuid', account['userInfo']['id'])
+ localStorage.setItem('selectedAccountId', account['id'])
localStorage.setItem('frontend2', account['serverInfo']['frontend2'])
bus.$emit('selected-account-reloaded')
}
@@ -213,6 +213,14 @@ export default {
query: serverInfoQuery
}
},
+ beforeMount() {
+ // Collect accounts from 'Accounts.db' by ruby sqlite3
+ sketchup.exec({name: "init_local_accounts", data: {}})
+ // Collect preferences to render UI according to it
+ sketchup.exec({name: "collect_preferences", data: {}})
+ // Collect versions to inform mixpanel
+ sketchup.exec({name: "collect_versions", data: {}})
+ },
mounted() {
bus.$on('selected-account-reloaded', async () => {
await onLogin(this.$apollo.provider.defaultClient)
@@ -233,21 +241,12 @@ export default {
this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch'
this.$vuetify.theme.dark = this.preferences.user.dark_theme
})
-
- // Collect versions to inform mixpanel
- sketchup.exec({name: "collect_versions", data: {}})
-
- // Collect preferences to render UI according to it
- sketchup.exec({name: "collect_preferences", data: {}})
-
- // Collect accounts from 'Accounts.db' by ruby sqlite3
- sketchup.exec({name: "init_local_accounts", data: {}})
},
methods: {
accounts() {
return JSON.parse(localStorage.getItem('localAccounts'))
},
- activeAccount(){
+ activeAccount() {
return JSON.parse(localStorage.getItem('selectedAccount'))
},
switchAccount(account) {
diff --git a/ui/src/vue-apollo.js b/ui/src/vue-apollo.js
index c5b2422..2383db5 100644
--- a/ui/src/vue-apollo.js
+++ b/ui/src/vue-apollo.js
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV === 'development') {
localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN)
localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER)
} else if (!localStorage.getItem('serverUrl')) {
- localStorage.setItem('serverUrl', 'https://speckle.xyz')
+ localStorage.setItem('serverUrl', 'https://app.speckle.systems')
}
const authLink = setContext((_, { headers }) => {
@@ -34,7 +34,7 @@ const defaultOptions = {
return (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
- : 'https://speckle.xyz') + '/graphql'
+ : 'https://app.speckle.systems') + '/graphql'
)
},
@@ -43,7 +43,7 @@ const defaultOptions = {
wsEndpoint: (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
- : 'https://speckle.xyz') + '/graphql'
+ : 'https://app.speckle.systems') + '/graphql'
).replace('http', 'ws'),
// LocalStorage token