mirror of
https://github.com/AppFlowy-IO/AppFlowy-Web.git
synced 2026-03-13 10:00:26 +08:00
chore: fix flickering version changed modal (#278)
This commit is contained in:
committed by
GitHub
parent
c498fcc9e0
commit
5cb5b116e6
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user