mirror of
https://github.com/dream-num/univer.git
synced 2026-08-31 01:42:03 +08:00
fix(workbook): sheet removal process (#6284)
This commit is contained in:
@@ -118,8 +118,9 @@ export class Workbook extends UnitModel<IWorkbookData, UniverInstanceType.UNIVER
|
||||
this._activeSheet$.complete();
|
||||
this._name$.complete();
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
this._worksheets.clear();
|
||||
const sheetIds = Array.from(this._worksheets.keys());
|
||||
sheetIds.forEach((id) => {
|
||||
this._removeSheet(id);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ export class Workbook extends UnitModel<IWorkbookData, UniverInstanceType.UNIVER
|
||||
this._activeSheet$.next(worksheet);
|
||||
}
|
||||
|
||||
removeSheet(sheetId: string): boolean {
|
||||
private _removeSheet(sheetId: string): boolean {
|
||||
const sheetToRemove = this._worksheets.get(sheetId);
|
||||
if (!sheetToRemove) {
|
||||
return false;
|
||||
@@ -281,12 +282,20 @@ export class Workbook extends UnitModel<IWorkbookData, UniverInstanceType.UNIVER
|
||||
|
||||
this._worksheets.delete(sheetId);
|
||||
this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(sheetId), 1);
|
||||
delete this._snapshot.sheets[sheetId];
|
||||
this._sheetDisposed$.next(sheetToRemove);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
removeSheet(sheetId: string): boolean {
|
||||
const success = this._removeSheet(sheetId);
|
||||
if (success) {
|
||||
delete this._snapshot.sheets[sheetId];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
getActiveSheetIndex(): number {
|
||||
const { sheetOrder } = this._snapshot;
|
||||
return sheetOrder.findIndex((sheetId) => {
|
||||
|
||||
Reference in New Issue
Block a user