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

Method switchRoom

packages/widget-sdk/src/resource/service.ts:235–267  ·  view source on GitHub ↗

* @description Simply handle the creation and destruction of rooms, and the creation of undoManager. * The point of this method is that it is the same as opening a datasheet, * but the concept of destroying/creating a room cannot exist in the "template", so this method is more pure, * only

(to: string)

Source from the content-addressed store, hash-verified

233 * @private
234 */
235 private async switchRoom(to: string) {
236 /**
237 * Special handling for form, from form to datasheet, there may not be room.
238 */
239 const collaEngineMap = this.roomService ? await this.roomService.leaveRoom() : undefined;
240 // Create a new room.
241 this.roomService = new RoomService(
242 RoomService.createRoomId(to),
243 this.socket,
244 () => this.socket.connected,
245 this.store,
246 collaEngineMap,
247 {
248 onError: (error: IError, type: 'modal' | 'subscribeUsage' = 'modal') => this.onError(error, type),
249 destroy: () => this.destroy(),
250 getRoomIOClear: () => {
251 return this.roomIOClear;
252 },
253 setRoomIOClear: (status: boolean) => {
254 return (this.roomIOClear = status);
255 },
256 getRoomLastSendTime: () => {
257 return this.roomLastSendTime;
258 },
259 setRoomLastSendTime: () => {
260 this.roomLastSendTime = Date.now();
261 },
262 },
263 this.fetchResource,
264 lsStore,
265 localForage
266 );
267 }
268
269 /**
270 * @description undoManager is bound to the main resource that created the room,

Callers 1

switchResourceMethod · 0.95

Calls 4

destroyMethod · 0.95
createRoomIdMethod · 0.80
leaveRoomMethod · 0.65
onErrorMethod · 0.65

Tested by

no test coverage detected