Skip to content

Commit

Permalink
fix(sheet): drawing switch tab position error (#2686)
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer authored Jul 4, 2024
1 parent 0c6f5ec commit e1549e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ export class ImageUpdateController extends Disposable {
(params).forEach(async (param) => {
const { unitId, subUnitId, drawingId } = param;
const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
const currentSubUnitId = getCurrentUnitInfo(this._currentUniverService)?.subUnitId;

if (renderObject == null) {
if (renderObject == null || currentSubUnitId !== subUnitId) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,34 +1159,38 @@ export class SheetDrawingTransformAffectedController extends Disposable implemen
this.disposeWithMe(
this._commandService.onCommandExecuted((command: ICommandInfo) => {
if (command.id === SetWorksheetActiveOperation.id) {
const params = command.params as ISetWorksheetActiveOperationParams;
const { unitId: showUnitId, subUnitId: showSubunitId } = params;
setTimeout(() => {
const params = command.params as ISetWorksheetActiveOperationParams;
const { unitId: showUnitId, subUnitId: showSubunitId } = params;

const drawingMap = this._drawingManagerService.drawingManagerData;
const drawingMap = this._drawingManagerService.drawingManagerData;

const insertDrawings: IDrawingParam[] = [];
const insertDrawings: IDrawingParam[] = [];

const removeDrawings: IDrawingParam[] = [];
const removeDrawings: IDrawingParam[] = [];

Object.keys(drawingMap).forEach((unitId) => {
const subUnitMap = drawingMap[unitId];
Object.keys(subUnitMap).forEach((subUnitId) => {
const drawingData = subUnitMap[subUnitId].data;
if (drawingData == null) {
return;
}
Object.keys(drawingData).forEach((drawingId) => {
if (unitId === showUnitId && subUnitId === showSubunitId) {
insertDrawings.push(drawingData[drawingId]);
} else {
removeDrawings.push(drawingData[drawingId]);
Object.keys(drawingMap).forEach((unitId) => {
const subUnitMap = drawingMap[unitId];
Object.keys(subUnitMap).forEach((subUnitId) => {
const drawingData = subUnitMap[subUnitId].data;
if (drawingData == null) {
return;
}
Object.keys(drawingData).forEach((drawingId) => {
if (unitId === showUnitId && subUnitId === showSubunitId) {
const drawing = drawingData[drawingId] as ISheetDrawing;
drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._sheetSkeletonManagerService);
insertDrawings.push(drawingData[drawingId]);
} else {
removeDrawings.push(drawingData[drawingId]);
}
});
});
});
});

this._drawingManagerService.removeNotification(removeDrawings);
this._drawingManagerService.addNotification(insertDrawings);
this._drawingManagerService.removeNotification(removeDrawings);
this._drawingManagerService.addNotification(insertDrawings);
}, 0);
}
})
);
Expand Down

0 comments on commit e1549e0

Please sign in to comment.