From 5cb5b116e6d7a0502c6773dee0d8d3086a05e2c5 Mon Sep 17 00:00:00 2001 From: Bartosz Sypytkowski Date: Thu, 12 Mar 2026 07:10:54 +0100 Subject: [PATCH] chore: fix flickering version changed modal (#278) --- src/@types/translations/en.json | 2 +- src/components/ws/sync/types.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/@types/translations/en.json b/src/@types/translations/en.json index 546dd0f7..c18337e0 100644 --- a/src/@types/translations/en.json +++ b/src/@types/translations/en.json @@ -3671,7 +3671,7 @@ "comingSoonToWeb": "Coming soon to the web 👋. You can use this feature right now on our desktop or mobile app." }, "versionHistory": { - "versionHistory": "Version History", + "versionHistory": "Page History", "all": "All", "last7Days": "Last 7 days", "last30Days": "Last 30 days", diff --git a/src/components/ws/sync/types.ts b/src/components/ws/sync/types.ts index 5802cf90..00f846a1 100644 --- a/src/components/ws/sync/types.ts +++ b/src/components/ws/sync/types.ts @@ -1,10 +1,12 @@ import * as awarenessProtocol from 'y-protocols/awareness'; -import { validate as uuidValidate } from 'uuid'; import { SyncContext } from '@/application/services/js-services/sync-protocol'; import { Types, YDoc } from '@/application/types'; import { collab, messages } from '@/proto/messages'; +const UUID_REGEX = + /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i; + export type SyncDocMeta = { object_id?: string; view_id?: string; @@ -75,10 +77,14 @@ export type SyncContextType = { }; export const isCollabVersionId = (value: string | null | undefined): value is string => { - return typeof value === 'string' && uuidValidate(value); + return typeof value === 'string' && UUID_REGEX.test(value); }; export const versionChanged = (context: SyncContext, message: collab.ICollabMessage): boolean => { + if (!message.update && !message.syncRequest) { + return false; // we only detect version changes for these two message types + } + const incomingVersion = message.update?.version || message.syncRequest?.version || null; const localVersion = context.doc.version; const incomingKnown = isCollabVersionId(incomingVersion);