* @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)
| 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, |
no test coverage detected