Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 016dbd97da |
@@ -53,6 +53,7 @@
|
||||
{{ hostAppStore.connectorVersion }}
|
||||
</div>
|
||||
<HeaderButton
|
||||
v-if="hostAppStore.isDistributedBySpeckle"
|
||||
v-tippy="'Documentation and help'"
|
||||
@click="
|
||||
app.$openUrl(
|
||||
|
||||
@@ -2,6 +2,16 @@ import type { ToastNotification } from '@speckle/ui-components'
|
||||
import { ToastNotificationType } from '@speckle/ui-components'
|
||||
import { useHostAppStore } from '~/store/hostApp'
|
||||
|
||||
export class UpdateError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message)
|
||||
this.name = 'FetchError'
|
||||
|
||||
// Required when extending Error in TypeScript
|
||||
Object.setPrototypeOf(this, new.target.prototype)
|
||||
}
|
||||
}
|
||||
|
||||
type Versions = {
|
||||
Versions: Version[]
|
||||
}
|
||||
@@ -35,24 +45,39 @@ export function useUpdateConnector() {
|
||||
}
|
||||
|
||||
async function getVersions() {
|
||||
const response = await fetch(
|
||||
`https://releases.speckle.dev/manager2/feeds/${hostApp.hostAppName?.toLowerCase()}-v3.json`,
|
||||
{
|
||||
method: 'GET'
|
||||
try {
|
||||
// End point to get list of versions that deployed by Speckle's pipeline
|
||||
const response = await fetch(
|
||||
`https://releases.speckle.dev/manager2/feeds/${hostApp.hostAppName?.toLowerCase()}-v3.json`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
// It is the only way to understand the connector is distributed by Speckle or not.
|
||||
throw new UpdateError('Failed to fetch versions')
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch versions')
|
||||
const data = (await response.json()) as unknown as Versions
|
||||
const sortedVersions = data.Versions.sort(function (a: Version, b: Version) {
|
||||
return new Date(b.Date).getTime() - new Date(a.Date).getTime()
|
||||
})
|
||||
versions.value = sortedVersions
|
||||
latestAvailableVersion.value = sortedVersions[0]
|
||||
hostApp.setLatestAvailableVersion(sortedVersions[0])
|
||||
} catch (err) {
|
||||
if (err instanceof TypeError && err.message === 'Failed to fetch') {
|
||||
// When user has network issue in between, actually it is not so likely because regardless user need network to be able to render netlify page
|
||||
throw new Error('Network error')
|
||||
} else if (err instanceof UpdateError) {
|
||||
// We set the flag to use it in relavant places, hide some documentation related buttons etc..
|
||||
hostApp.setIsDistributedBySpeckle(false)
|
||||
} else {
|
||||
// Rest of the possibilites that we trigger toast
|
||||
throw new Error('Unknown error occurred')
|
||||
}
|
||||
}
|
||||
|
||||
const data = (await response.json()) as unknown as Versions
|
||||
const sortedVersions = data.Versions.sort(function (a: Version, b: Version) {
|
||||
return new Date(b.Date).getTime() - new Date(a.Date).getTime()
|
||||
})
|
||||
versions.value = sortedVersions
|
||||
latestAvailableVersion.value = sortedVersions[0]
|
||||
hostApp.setLatestAvailableVersion(sortedVersions[0])
|
||||
}
|
||||
|
||||
return { checkUpdate }
|
||||
|
||||
+4
-1
@@ -69,7 +69,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- TEMPORARY MESSAGE TO USER! will be deleted -->
|
||||
<div class="mt-2 bg-highlight-1 rounded-md p-2">
|
||||
<div
|
||||
v-if="store.isDistributedBySpeckle"
|
||||
class="mt-2 bg-highlight-1 rounded-md p-2"
|
||||
>
|
||||
<h1
|
||||
class="text-heading-sm w-full bg-gradient-to-r from-blue-500 via-blue-400 to-blue-600 inline-block py-1 text-transparent bg-clip-text"
|
||||
>
|
||||
|
||||
@@ -43,6 +43,7 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
|
||||
const accountsStore = useAccountStore()
|
||||
const { checkUpdate } = useUpdateConnector()
|
||||
|
||||
const isDistributedBySpeckle = ref<boolean>(true)
|
||||
const latestAvailableVersion = ref<Version | null>(null)
|
||||
|
||||
const currentNotification = ref<Nullable<ToastNotification>>(null)
|
||||
@@ -85,6 +86,10 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
|
||||
hostAppError.value = error
|
||||
}
|
||||
|
||||
const setIsDistributedBySpeckle = (val: boolean) => {
|
||||
isDistributedBySpeckle.value = val
|
||||
}
|
||||
|
||||
/**
|
||||
* Model Card Operations
|
||||
*/
|
||||
@@ -734,6 +739,8 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
|
||||
availableViews,
|
||||
navisworksAvailableSavedSets,
|
||||
availableSelectSendFilters,
|
||||
isDistributedBySpeckle,
|
||||
setIsDistributedBySpeckle,
|
||||
setNotification,
|
||||
setModelError,
|
||||
setLatestAvailableVersion,
|
||||
|
||||
Reference in New Issue
Block a user