diff --git a/editor/src/components/editor/editor-component.tsx b/editor/src/components/editor/editor-component.tsx index ced74c145447..449581a0239c 100644 --- a/editor/src/components/editor/editor-component.tsx +++ b/editor/src/components/editor/editor-component.tsx @@ -58,7 +58,7 @@ import { generateUUID } from '../../utils/utils' import { isLiveblocksEnabled } from './liveblocks-utils' import type { Storage, Presence, RoomEvent, UserMeta } from '../../../liveblocks.config' import LiveblocksProvider from '@liveblocks/yjs' -import { projectIdToRoomId } from '../../core/shared/multiplayer' +import { isRoomId, projectIdToRoomId } from '../../core/shared/multiplayer' import { useDisplayOwnershipWarning } from './project-owner-hooks' const liveModeToastId = 'play-mode-toast' @@ -298,11 +298,10 @@ export const EditorComponentInner = React.memo((props: EditorProps) => { ) React.useEffect(() => { - if (yDoc != null) { + if (yDoc != null && isRoomId(room.id)) { const yProvider = new LiveblocksProvider(room, yDoc) return () => { - yDoc.destroy() yProvider.destroy() } } diff --git a/editor/src/core/shared/multiplayer.ts b/editor/src/core/shared/multiplayer.ts index a12c6d841fa8..39ae86a6dfe8 100644 --- a/editor/src/core/shared/multiplayer.ts +++ b/editor/src/core/shared/multiplayer.ts @@ -128,6 +128,12 @@ export function canFollowTarget( return !followChain.has(selfId) } +const roomIdPrefix = `project-room-` + export function projectIdToRoomId(projectId: string): string { - return `project-room-${projectId}` + return `${roomIdPrefix}${projectId}` +} + +export function isRoomId(s: string): boolean { + return s.startsWith(roomIdPrefix) }