@@ -176,13 +176,16 @@ export function createWebSocketConnection( serverUrl: string ): ProviderCreator
176176
177177 return async function (
178178 objectType : ObjectType ,
179- objectId : ObjectID ,
179+ objectId : ObjectID | null ,
180180 doc : Y . Doc ,
181181 awareness ?: Awareness
182182 ) {
183183 try {
184- // For now, we only support traditional post types.
185- if ( ! objectType . startsWith ( 'postType/' ) || ! parseInt ( objectId , 10 ) ) {
184+ // For now, we only support collections and traditional post types.
185+ if (
186+ null !== objectId &&
187+ ( ! objectType . startsWith ( 'postType/' ) || ! parseInt ( objectId , 10 ) )
188+ ) {
186189 logger . debug ( 'WebSocket connection skipped for unsupported object' , {
187190 objectType,
188191 objectId,
@@ -198,10 +201,10 @@ export function createWebSocketConnection( serverUrl: string ): ProviderCreator
198201 * multisite. We don't sync entities like those yet. When we do, we'll need to revisit
199202 * adding the blog ID to the room name as that won't be needed.
200203 */
201- const roomName = `site-${ BLOG_ID ?? 1 } /${ objectType } -${ objectId } ` ;
204+ const roomName = `site-${ BLOG_ID ?? 1 } /${ objectType } -${ objectId ?? 'collection' } ` ;
202205 const options = { ...config . options , awareness } ;
203206 const provider = new WebsocketProvider ( config . serverUrl , roomName , doc , options ) ;
204- const connect = createConnect ( provider , objectType , objectId ) ;
207+ const connect = createConnect ( provider , objectType , objectId ?? 'collection' ) ;
205208
206209 provider . on ( 'connection-close' , connect ) ;
207210 provider . on ( 'connection-error' , ( ) => {
0 commit comments