mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 12:25:17 +00:00
Prevent infinity reload wher version mismatch (#5967)
This commit is contained in:
parent
96d71b1334
commit
51028108c7
@ -149,11 +149,6 @@ export function tableToCSV (tableId: string, separator = ','): string {
|
||||
return csv.join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const networkStatus = writable<number>(0)
|
||||
|
||||
let attractorMx: number | undefined
|
||||
let attractorMy: number | undefined
|
||||
|
||||
|
@ -16,6 +16,7 @@ import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLoc
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
export const versionError = writable<string | undefined>(undefined)
|
||||
const versionStorageKey = 'last_server_version'
|
||||
|
||||
let _token: string | undefined
|
||||
let _client: AccountClient | undefined
|
||||
@ -103,7 +104,14 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
|
||||
console.log('Server version', serverVersion.version)
|
||||
if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) {
|
||||
location.reload()
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
if (sessionStorage.getItem(versionStorageKey) !== serverVersion.version) {
|
||||
sessionStorage.setItem(versionStorageKey, serverVersion.version)
|
||||
location.reload()
|
||||
}
|
||||
} else {
|
||||
location.reload()
|
||||
}
|
||||
versionError.set(`${currentVersionStr} => ${serverVersion.version}`)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import core, {
|
||||
type Version
|
||||
} from '@hcengineering/core'
|
||||
import login, { loginId } from '@hcengineering/login'
|
||||
import { addEventListener, broadcastEvent, getMetadata, getResource, setMetadata } from '@hcengineering/platform'
|
||||
import { broadcastEvent, getMetadata, getResource, setMetadata } from '@hcengineering/platform'
|
||||
import presentation, {
|
||||
closeClient,
|
||||
getCurrentWorkspaceUrl,
|
||||
@ -27,7 +27,6 @@ import {
|
||||
getCurrentLocation,
|
||||
locationStorageKeyId,
|
||||
navigate,
|
||||
networkStatus,
|
||||
setMetadataLocalStorage
|
||||
} from '@hcengineering/ui'
|
||||
import { writable } from 'svelte/store'
|
||||
@ -35,15 +34,12 @@ import plugin from './plugin'
|
||||
import { workspaceCreating } from './utils'
|
||||
|
||||
export const versionError = writable<string | undefined>(undefined)
|
||||
const versionStorageKey = 'last_server_version'
|
||||
|
||||
let _token: string | undefined
|
||||
let _client: AccountClient | undefined
|
||||
let _clientSet: boolean = false
|
||||
|
||||
addEventListener(client.event.NetworkRequests, async (event: string, val: number) => {
|
||||
networkStatus.set(val)
|
||||
})
|
||||
|
||||
export async function disconnect (): Promise<void> {
|
||||
if (_client !== undefined) {
|
||||
await _client.close()
|
||||
@ -211,7 +207,14 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
version !== undefined ? versionToString(version) : ''
|
||||
)
|
||||
if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) {
|
||||
location.reload()
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
if (sessionStorage.getItem(versionStorageKey) !== serverVersion.version) {
|
||||
sessionStorage.setItem(versionStorageKey, serverVersion.version)
|
||||
location.reload()
|
||||
}
|
||||
} else {
|
||||
location.reload()
|
||||
}
|
||||
versionError.set(`${currentVersionStr} => ${serverVersion.version}`)
|
||||
} else {
|
||||
versionError.set(undefined)
|
||||
|
Loading…
Reference in New Issue
Block a user