MCPcopy Create free account
hub / github.com/apitable/apitable / watch

Method watch

packages/core/src/sync/room.ts:309–334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

307 */
308 @errorCapture<RoomService>()
309 async watch() {
310 const state = this.store.getState();
311 const shareId = state.pageParams.shareId;
312 const embedId = state.pageParams.embedId;
313 const watchResponse = await this.io.watch<IWatchResponse, any>(this.roomId, shareId, embedId).catch((e) => {
314 throw new EnhanceError(e);
315 });
316
317 this.setConnected(true);
318 if (!watchResponse) {
319 return;
320 }
321 const { resourceRevisions, collaborators } = watchResponse.data!;
322 // console.log('resourceRevisions:', resourceRevisions);
323 const collaEngine = this.collaEngineMap.get(this.roomId);
324 if (!collaEngine) {
325 return;
326 }
327 await this.checkVersion(resourceRevisions);
328 const resourceType = collaEngine.resourceType;
329 this.store.dispatch(roomInfoSync(this.roomId, resourceType, collaborators || []));
330 this.store.dispatch(setResourceConnect(this.roomId, resourceType));
331 this.loadFieldPermissionMap();
332 this.bindSocketMessage();
333 this.setSendingWatcher();
334 }
335
336 /**
337 * Switching resources or reconnecting after disconnection requires the column permissions of all data tables in the room

Callers 1

initMethod · 0.95

Calls 9

setConnectedMethod · 0.95
checkVersionMethod · 0.95
setSendingWatcherMethod · 0.95
roomInfoSyncFunction · 0.90
setResourceConnectFunction · 0.90
getMethod · 0.65
catchMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected