Merge pull request #17 from Jeff-Emmett/add-runpod-AI-API
fix: use repo.create() instead of invalid document ID format
This commit is contained in:
commit
fde305abf6
|
|
@ -116,16 +116,14 @@ export function useAutomergeSync(config: AutomergeSyncConfig): TLStoreWithStatus
|
||||||
console.log("🔌 Initializing Automerge Repo with NetworkAdapter for room:", roomId)
|
console.log("🔌 Initializing Automerge Repo with NetworkAdapter for room:", roomId)
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
// CRITICAL: Use repo.find() with a consistent document ID based on roomId
|
// CRITICAL: Create or find the document for this room
|
||||||
// This ensures all windows/tabs share the same Automerge document and can sync properly
|
// We use repo.create() which generates a proper Automerge document ID
|
||||||
// Format: automerge:${roomId} matches what the server expects (see AutomergeDurableObject.ts line 327)
|
// The document will be shared across clients via the WebSocket sync protocol
|
||||||
const documentId = `automerge:${roomId}` as any
|
console.log(`🔌 Creating Automerge document for room: ${roomId}`)
|
||||||
console.log(`🔌 Finding or creating Automerge document with ID: ${documentId}`)
|
|
||||||
|
|
||||||
// Use repo.find() to get or create the document with this ID
|
// Create a new document - Automerge will generate a proper document ID
|
||||||
// This ensures all windows share the same document instance
|
// All clients connecting to the same room will sync via the WebSocket
|
||||||
// Note: repo.find() returns a Promise, so we await it
|
const handle = repo.create<TLStoreSnapshot>()
|
||||||
const handle = await repo.find(documentId)
|
|
||||||
|
|
||||||
console.log("Found/Created Automerge handle via Repo:", {
|
console.log("Found/Created Automerge handle via Repo:", {
|
||||||
handleId: handle.documentId,
|
handleId: handle.documentId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue