From 12f93d5c5e239be91d09bfedddb23b1a47d7d3bc Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Fri, 6 Dec 2024 23:19:14 +0700 Subject: [PATCH 1/3] fix: better error handling in json migration (#7279) Signed-off-by: Alexander Onnikov --- models/core/src/migration.ts | 55 +++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/models/core/src/migration.ts b/models/core/src/migration.ts index 6cae6354c7..ccebe20b86 100644 --- a/models/core/src/migration.ts +++ b/models/core/src/migration.ts @@ -352,7 +352,9 @@ async function processMigrateJsonForDoc ( if (value.startsWith('{')) { // For some reason we have documents that are already markups - const jsonId = await saveCollabJson(ctx, storageAdapter, workspaceId, collabId, value) + const jsonId = await retry(5, async () => { + return await saveCollabJson(ctx, storageAdapter, workspaceId, collabId, value) + }) update[attributeName] = jsonId continue } @@ -371,23 +373,28 @@ async function processMigrateJsonForDoc ( // If document id has changed, save it with new name to ensure we will be able to load it later const ydocId = makeCollabYdocId(collabId) if (ydocId !== currentYdocId) { - ctx.info('saving collaborative doc with new name', { collabId, ydocId, currentYdocId }) - const buffer = await storageAdapter.read(ctx, workspaceId, currentYdocId) - await storageAdapter.put( - ctx, - workspaceId, - ydocId, - Buffer.concat(buffer as any), - 'application/ydoc', - buffer.length - ) + await retry(5, async () => { + const stat = await storageAdapter.stat(ctx, workspaceId, currentYdocId) + if (stat !== undefined) { + const buffer = await storageAdapter.read(ctx, workspaceId, currentYdocId) + await storageAdapter.put( + ctx, + workspaceId, + ydocId, + Buffer.concat(buffer as any), + 'application/ydoc', + buffer.length + ) + } + }) } - - const unset = update.$unset ?? {} - update.$unset = { ...unset, [attribute.name]: 1 } - } catch (err: any) { - ctx.warn('failed to process collaborative doc', { workspaceId, collabId, currentYdocId, err: err.message }) + } catch (err) { + const error = err instanceof Error ? err.message : String(err) + ctx.warn('failed to process collaborative doc', { workspaceId, collabId, currentYdocId, error }) } + + const unset = update.$unset ?? {} + update.$unset = { ...unset, [attribute.name]: 1 } } return update @@ -510,3 +517,19 @@ export const coreOperation: MigrateOperation = { ]) } } + +async function retry (retries: number, op: () => Promise): Promise { + let error: any + while (retries > 0) { + retries-- + try { + return await op() + } catch (err: any) { + error = err + if (retries !== 0) { + await new Promise((resolve) => setTimeout(resolve, 50)) + } + } + } + throw error +} From 6ddcdd5d1bab9481ea55fe39ffa0c11e827115db Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 6 Dec 2024 22:15:32 +0500 Subject: [PATCH 2/3] Fix office sidebar (#7283) Signed-off-by: Denis Bykhov --- models/love/src/index.ts | 3 +- .../src/components/FloorPreview.svelte | 9 +- .../src/components/Floors.svelte | 105 ------------------ .../love-resources/src/components/Hall.svelte | 27 +++-- .../src/components/LoveWidget.svelte | 102 +++++++++-------- plugins/love-resources/src/stores.ts | 1 + 6 files changed, 71 insertions(+), 176 deletions(-) delete mode 100644 plugins/love-resources/src/components/Floors.svelte diff --git a/models/love/src/index.ts b/models/love/src/index.ts index a5222eeef7..9457c67b8b 100644 --- a/models/love/src/index.ts +++ b/models/love/src/index.ts @@ -275,8 +275,7 @@ export function createModel (builder: Builder): void { label: love.string.Office, type: WidgetType.Fixed, icon: love.icon.Love, - component: love.component.LoveWidget, - headerLabel: love.string.Office + component: love.component.LoveWidget }, love.ids.LoveWidget ) diff --git a/plugins/love-resources/src/components/FloorPreview.svelte b/plugins/love-resources/src/components/FloorPreview.svelte index a055751e95..7e5372e1ac 100644 --- a/plugins/love-resources/src/components/FloorPreview.svelte +++ b/plugins/love-resources/src/components/FloorPreview.svelte @@ -86,14 +86,7 @@ let pressed: boolean = false const clickMore = (e: MouseEvent): void => { pressed = true - const value: SelectPopupValueType[] = [ - { - id: 'configure', - icon: IconSettings, - label: configure ? plugin.string.FinalizeEditing : plugin.string.EditOffice - }, - { id: 'rename', icon: IconEdit, label: plugin.string.RenameAFloor } - ] + const value: SelectPopupValueType[] = [{ id: 'rename', icon: IconEdit, label: plugin.string.RenameAFloor }] showPopup(SelectPopup, { value }, eventToHTMLElement(e), (result) => { if (result === 'configure') { dispatch('configure', floor) diff --git a/plugins/love-resources/src/components/Floors.svelte b/plugins/love-resources/src/components/Floors.svelte deleted file mode 100644 index ba1a66d752..0000000000 --- a/plugins/love-resources/src/components/Floors.svelte +++ /dev/null @@ -1,105 +0,0 @@ - - - -{#if $deviceInfo.navigator.visible} -
-
-
- - - {#if editable} - - {/if} -
- - {#each $floors as _floor} - { - if (floor === _floor._id) { - configure = !configure - } else { - floor = _floor._id - configure = true - } - }} - on:select={() => { - floor = _floor._id - }} - /> - {/each} - -
- -
- -{/if} diff --git a/plugins/love-resources/src/components/Hall.svelte b/plugins/love-resources/src/components/Hall.svelte index 26808c0361..829ee04544 100644 --- a/plugins/love-resources/src/components/Hall.svelte +++ b/plugins/love-resources/src/components/Hall.svelte @@ -20,17 +20,26 @@ import { getClient } from '@hcengineering/presentation' import { deviceOptionsStore as deviceInfo, getCurrentLocation, navigate } from '@hcengineering/ui' import { onDestroy, onMount } from 'svelte' - import { activeFloor, floors, infos, invites, myInfo, myRequests, rooms, storePromise } from '../stores' + import { + activeFloor, + floors, + infos, + invites, + myInfo, + myRequests, + rooms, + selectedFloor, + storePromise + } from '../stores' import { connectToMeeting, tryConnect } from '../utils' import Floor from './Floor.svelte' import FloorConfigure from './FloorConfigure.svelte' - import Floors from './Floors.svelte' function getRooms (rooms: Room[], floor: Ref): Room[] { return rooms.filter((p) => p.floor === floor) } - let selectedFloor = $activeFloor === '' ? $floors[0]?._id : $activeFloor + $: floor = $selectedFloor ?? ($activeFloor === '' ? $floors[0]?._id : $activeFloor) let configure: boolean = false let replacedPanel: HTMLElement @@ -73,21 +82,15 @@ }) -
{#if configure} (configure = false)} /> {:else} - (configure = true)} - on:open - /> + (configure = true)} on:open /> {/if}
diff --git a/plugins/love-resources/src/components/LoveWidget.svelte b/plugins/love-resources/src/components/LoveWidget.svelte index fda8cfb3b0..ed6fea387e 100644 --- a/plugins/love-resources/src/components/LoveWidget.svelte +++ b/plugins/love-resources/src/components/LoveWidget.svelte @@ -13,74 +13,78 @@ // limitations under the License. --> +
+ + + {#if editable} + + {/if} + +
- {#if floorsSelector} - {#each $floors as _floor} - { - selectFloor(_floor._id) - }} - /> - {/each} - {:else if selectedFloor} + {#each $floors as _floor} { + if (floor?._id === _floor._id) { + configure = !configure + } else { + selectedFloor.set(_floor?._id) + floor = _floor + configure = true + } + }} + on:select={() => { + selectedFloor.set(_floor?._id) + floor = _floor + }} /> - {/if} + {/each}
- {#if floorsSelector || $floors.length > 1} - - {/if}
diff --git a/plugins/love-resources/src/stores.ts b/plugins/love-resources/src/stores.ts index 26a1538a13..a0780768c8 100644 --- a/plugins/love-resources/src/stores.ts +++ b/plugins/love-resources/src/stores.ts @@ -34,6 +34,7 @@ export const currentRoom = derived([rooms, myInfo], ([rooms, myInfo]) => { return myInfo !== undefined ? rooms.find((p) => p._id === myInfo.room) : undefined }) export const floors = writable([]) +export const selectedFloor = writable | undefined>(undefined) export const activeFloor = derived([rooms, myInfo, myOffice], ([rooms, myInfo, myOffice]) => { let res: Ref | undefined if (myInfo !== undefined) { From ae1cedacbbfedb81571d4a0d918d13adf1ac7f1a Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Sat, 7 Dec 2024 00:23:43 +0700 Subject: [PATCH 3/3] Increase heap limit (#7284) Signed-off-by: Andrey Sobolev --- desktop/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/package.json b/desktop/package.json index a640770c88..d2fa29cb2b 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -8,7 +8,7 @@ "build:watch": "tsc", "_phase:package": "rushx package", "_phase:validate": "compile validate", - "package": "rushx bump && cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production webpack --stats-error-details && echo 'done'", + "package": "rushx bump && cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production NODE_OPTIONS='--max-old-space-size=4094' webpack --stats-error-details && echo 'done'", "webpack": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=development webpack --stats-error-details --progress -w", "devp": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=production CLIENT_TYPE=dev webpack --progress -w", "dev": "cross-env MODEL_VERSION=$(node ../common/scripts/show_version.js) VERSION=$(node ../common/scripts/show_tag.js) NODE_ENV=development webpack --progress -w",