From 630ae21a661c33908e40250e904eae8f863d3cb7 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 4 Jul 2024 08:48:11 +0700 Subject: [PATCH] UBERF-7489: Some more chat optimizations (#5999) --- .../src/components/ChannelScrollView.svelte | 30 +++-- plugins/chunter-resources/src/utils.ts | 117 ++++++++++-------- .../src/components/viewer/ImageViewer.svelte | 11 ++ server/backup/src/backup.ts | 4 + server/front/src/index.ts | 20 ++- 5 files changed, 117 insertions(+), 65 deletions(-) diff --git a/plugins/chunter-resources/src/components/ChannelScrollView.svelte b/plugins/chunter-resources/src/components/ChannelScrollView.svelte index 24af96e288..b8f88da1c1 100644 --- a/plugins/chunter-resources/src/components/ChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ChannelScrollView.svelte @@ -13,36 +13,36 @@ // limitations under the License. --> {#await p then blobRef} + {#if loading} +
+ +
+ {/if} { + loading = false + }} class="object-contain mx-auto" style:max-width={width} style:max-height={height} src={blobRef.src} srcset={blobRef.srcset} alt={name} + style:height={loading ? '0' : ''} /> {/await} diff --git a/server/backup/src/backup.ts b/server/backup/src/backup.ts index ea256d4e0d..2676fda96a 100644 --- a/server/backup/src/backup.ts +++ b/server/backup/src/backup.ts @@ -1198,6 +1198,10 @@ export async function restore ( async function sendChunk (doc: Doc | undefined, len: number): Promise { if (doc !== undefined) { docsToAdd.delete(doc._id) + if (opt.recheck === true) { + // We need to clear %hash% in case our is wrong. + delete (doc as any)['%hash%'] + } docs.push(doc) } sendSize = sendSize + len diff --git a/server/front/src/index.ts b/server/front/src/index.ts index 570e0076c1..27fddd533c 100644 --- a/server/front/src/index.ts +++ b/server/front/src/index.ts @@ -15,7 +15,7 @@ // import { Analytics } from '@hcengineering/analytics' -import { MeasureContext, Blob as PlatformBlob, WorkspaceId, metricsAggregate } from '@hcengineering/core' +import { MeasureContext, Blob as PlatformBlob, WorkspaceId, metricsAggregate, type Ref } from '@hcengineering/core' import { Token, decodeToken } from '@hcengineering/server-token' import { StorageAdapter, removeAllObjects } from '@hcengineering/storage' import bp from 'body-parser' @@ -798,8 +798,22 @@ async function getGeneratePreview ( pipeline.destroy() // Add support of avif as well. - await config.storageAdapter.put(ctx, payload.workspace, sizeId, dataBuff, contentType, dataBuff.length) - return (await config.storageAdapter.stat(ctx, payload.workspace, sizeId)) ?? blob + const upload = await config.storageAdapter.put( + ctx, + payload.workspace, + sizeId, + dataBuff, + contentType, + dataBuff.length + ) + return { + ...blob, + _id: sizeId as Ref, + size: dataBuff.length, + contentType, + etag: upload.etag, + storageId: sizeId + } } catch (err: any) { Analytics.handleError(err) ctx.error('failed to resize image', {