(resourceRevisions: IResourceRevision[] | null)
| 349 | |
| 350 | @errorCapture<RoomService>() |
| 351 | async checkVersion(resourceRevisions: IResourceRevision[] | null) { |
| 352 | const missVersionEngines: { collaEngine: Engine; revision: number }[] = []; |
| 353 | |
| 354 | if (!resourceRevisions || !resourceRevisions.length) { |
| 355 | console.log('The current resource has not been operated for a long time, and the data is automatically updated'); |
| 356 | await this.collaEngineMap.get(this.roomId)?.event.reloadResourceData(); |
| 357 | return; |
| 358 | } |
| 359 | |
| 360 | for (const { resourceId, revision } of resourceRevisions) { |
| 361 | const collaEngine = this.collaEngineMap.get(resourceId); |
| 362 | |
| 363 | if (!collaEngine) { |
| 364 | continue; |
| 365 | } |
| 366 | |
| 367 | const baseRevision = collaEngine.getRevision(); |
| 368 | const versionDiffs = numbersBetween(baseRevision, revision + 1); |
| 369 | if (!versionDiffs.length) { |
| 370 | continue; |
| 371 | } |
| 372 | if (versionDiffs.length >= 100) { |
| 373 | throw new EnhanceError({ |
| 374 | code: StatusCode.FRONT_VERSION_ERROR, |
| 375 | message: t(Strings.changeset_diff_big_tip), |
| 376 | modalType: ModalType.Info, |
| 377 | }); |
| 378 | } |
| 379 | missVersionEngines.push({ collaEngine, revision }); |
| 380 | } |
| 381 | |
| 382 | return await Promise.all( |
| 383 | missVersionEngines.map<Promise<any>>(({ collaEngine, revision }) => { |
| 384 | return collaEngine.prepare(revision + 1); |
| 385 | }) |
| 386 | ); |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * @description unwatch no longer needs to pay attention to whether the coordinator queue is emptied, |
no test coverage detected