aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/DocumentDecorations.tsx28
-rw-r--r--src/client/views/GlobalKeyHandler.ts2
2 files changed, 20 insertions, 10 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index e412d39ac..2914e5ad4 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -144,18 +144,28 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P
return true;
}
- _iconifyTimeout: NodeJS.Timeout | undefined;
+ _iconifyingCount = 0;
+ _deleteAfterIconify = false;
+ _iconifyBatch: UndoManager.Batch | undefined;
onCloseClick = (force = false) => {
if (this.canDelete) {
const views = SelectionManager.Views().slice().filter(v => v);
- const icons = this._iconifyTimeout || force ? views : views.filter(view => view.rootDoc.layoutKey === "layout_icon");
- const others = this._iconifyTimeout || force ? [] : views.filter(view => view.rootDoc.layoutKey !== "layout_icon");
- icons.forEach(iconView => iconView.props.removeDocument?.(iconView.props.Document));
- others.forEach(dv => dv.iconify());
- others.length && (this._iconifyTimeout = setTimeout(() => {
- views.forEach(view => SelectionManager.DeselectView(view));
- this._iconifyTimeout = undefined;
- }, 1000));
+ if (force) this._deleteAfterIconify = true;
+ if (!this._iconifyBatch) this._iconifyBatch = UndoManager.StartBatch("iconifying");
+ else this._deleteAfterIconify = true;
+ this._iconifyingCount = views.length;
+ const finished = () => {
+ if (this._deleteAfterIconify || --this._iconifyingCount <= 0) {
+ this._iconifyingCount = 0;
+ SelectionManager.DeselectAll();
+ if (this._deleteAfterIconify) views.forEach(iconView => iconView.props.removeDocument?.(iconView.props.Document));
+ this._deleteAfterIconify = false;
+ this._iconifyBatch?.end();
+ this._iconifyBatch = undefined;
+ }
+ }
+ if (!this._deleteAfterIconify) views.forEach(dv => dv.iconify(finished));
+ else finished();
}
}
onMaximizeDown = (e: React.PointerEvent) => {
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index e3031d2c5..6120c4c9e 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -147,7 +147,7 @@ export class KeyManager {
LightboxView.SetLightboxDoc(undefined);
SelectionManager.DeselectAll();
}
- else DocumentDecorations.Instance.onCloseClick();
+ else DocumentDecorations.Instance.onCloseClick(true);
}, "backspace");
// const selected = SelectionManager.Views().filter(dv => !dv.topMost);
// UndoManager.RunInBatch(() => {