diff --git a/packages/core/src/tx.ts b/packages/core/src/tx.ts index 27de10f894..f0802bd0a0 100644 --- a/packages/core/src/tx.ts +++ b/packages/core/src/tx.ts @@ -48,7 +48,6 @@ export interface Tx extends Doc { */ export enum WorkspaceEvent { UpgradeScheduled, - Upgrade, IndexingUpdate, SecurityChange, MaintenanceNotification, diff --git a/plugins/client-resources/src/connection.ts b/plugins/client-resources/src/connection.ts index 47afd656ba..c4c8a6a59c 100644 --- a/plugins/client-resources/src/connection.ts +++ b/plugins/client-resources/src/connection.ts @@ -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 diff --git a/plugins/client-resources/src/index.ts b/plugins/client-resources/src/index.ts index 3c9a044144..ebbf954e45 100644 --- a/plugins/client-resources/src/index.ts +++ b/plugins/client-resources/src/index.ts @@ -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 diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index 681cb0d93a..f92898add2 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -94,7 +94,7 @@ export async function connect (title: string): Promise { 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 { console.log('Server version', serverVersion.version) if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) { + location.reload() versionError.set(`${currentVersionStr} => ${serverVersion.version}`) } } diff --git a/plugins/workbench-resources/src/connect.ts b/plugins/workbench-resources/src/connect.ts index 3ad7fcf374..784e9ad8ee 100644 --- a/plugins/workbench-resources/src/connect.ts +++ b/plugins/workbench-resources/src/connect.ts @@ -196,7 +196,7 @@ export async function connect (title: string): Promise { 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 { version !== undefined ? versionToString(version) : '' ) if (serverVersion.version !== '' && serverVersion.version !== currentVersionStr) { + location.reload() versionError.set(`${currentVersionStr} => ${serverVersion.version}`) } else { versionError.set(undefined)