mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Reload when upgrade (#5942)
This commit is contained in:
parent
bb87db700c
commit
4fb5ca1d17
@ -48,7 +48,6 @@ export interface Tx extends Doc {
|
||||
*/
|
||||
export enum WorkspaceEvent {
|
||||
UpgradeScheduled,
|
||||
Upgrade,
|
||||
IndexingUpdate,
|
||||
SecurityChange,
|
||||
MaintenanceNotification,
|
||||
|
@ -38,8 +38,6 @@ import core, {
|
||||
TxApplyIf,
|
||||
TxHandler,
|
||||
TxResult,
|
||||
TxWorkspaceEvent,
|
||||
WorkspaceEvent,
|
||||
generateId,
|
||||
toFindResult
|
||||
} from '@hcengineering/core'
|
||||
@ -356,10 +354,7 @@ class Connection implements ClientConnection {
|
||||
const txArr = Array.isArray(resp.result) ? (resp.result as Tx[]) : [resp.result as Tx]
|
||||
|
||||
for (const tx of txArr) {
|
||||
if (
|
||||
(tx?._class === core.class.TxWorkspaceEvent && (tx as TxWorkspaceEvent).event === WorkspaceEvent.Upgrade) ||
|
||||
tx?._class === core.class.TxModelUpgrade
|
||||
) {
|
||||
if (tx?._class === core.class.TxModelUpgrade) {
|
||||
console.log('Processing upgrade', this.workspace, this.email)
|
||||
this.onUpgrade?.()
|
||||
return
|
||||
|
@ -94,11 +94,13 @@ export default async () => {
|
||||
|
||||
const upgradeHandler: TxHandler = (...txes: Tx[]) => {
|
||||
for (const tx of txes) {
|
||||
if (tx?._class === core.class.TxModelUpgrade) {
|
||||
onUpgrade?.()
|
||||
return
|
||||
}
|
||||
if (tx?._class === core.class.TxWorkspaceEvent) {
|
||||
const event = tx as TxWorkspaceEvent
|
||||
if (event.event === WorkspaceEvent.Upgrade) {
|
||||
onUpgrade?.()
|
||||
} else if (event.event === WorkspaceEvent.MaintenanceNotification) {
|
||||
if (event.event === WorkspaceEvent.MaintenanceNotification) {
|
||||
void setPlatformStatus(
|
||||
new Status(Severity.WARNING, platform.status.MaintenanceWarning, {
|
||||
time: event.params.timeMinutes
|
||||
|
@ -94,7 +94,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
|
||||
if (currentVersionStr !== reconnectVersionStr) {
|
||||
// It seems upgrade happened
|
||||
// location.reload()
|
||||
location.reload()
|
||||
versionError.set(`${currentVersionStr} != ${reconnectVersionStr}`)
|
||||
}
|
||||
const serverVersion: { version: string } = await (
|
||||
@ -103,6 +103,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
|
||||
console.log('Server version', serverVersion.version)
|
||||
if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) {
|
||||
location.reload()
|
||||
versionError.set(`${currentVersionStr} => ${serverVersion.version}`)
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
|
||||
if (currentVersionStr !== reconnectVersionStr) {
|
||||
// It seems upgrade happened
|
||||
// location.reload()
|
||||
location.reload()
|
||||
versionError.set(`${currentVersionStr} != ${reconnectVersionStr}`)
|
||||
}
|
||||
const serverVersion: { version: string } = await ctx.with(
|
||||
@ -211,6 +211,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
version !== undefined ? versionToString(version) : ''
|
||||
)
|
||||
if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) {
|
||||
location.reload()
|
||||
versionError.set(`${currentVersionStr} => ${serverVersion.version}`)
|
||||
} else {
|
||||
versionError.set(undefined)
|
||||
|
Loading…
Reference in New Issue
Block a user