diff options
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index d9c206032..1feb643df 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -144,29 +144,30 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P return true; } - _iconifyingCount = 0; _deleteAfterIconify = false; _iconifyBatch: UndoManager.Batch | undefined; onCloseClick = (force = false) => { if (this.canDelete) { const views = SelectionManager.Views().slice().filter(v => v); - if (force) this._deleteAfterIconify = true; + this._deleteAfterIconify = force || this._iconifyBatch ? true : false; if (!this._iconifyBatch) { this._iconifyBatch = UndoManager.StartBatch("iconifying"); - this._iconifyingCount = force ? 1 : views.length; - } else this._deleteAfterIconify = true; - const finished = () => { - if (--this._iconifyingCount <= 0) { - this._iconifyingCount = 0; - SelectionManager.DeselectAll(); - if (this._deleteAfterIconify) views.forEach(iconView => iconView.props.removeDocument?.(iconView.props.Document)); - this._deleteAfterIconify = false; + } else { + force = false; // can't force immediate close in the middle of iconifying -- have to wait until iconifying completes + } + var iconifyingCount = views.length; + const finished = action((force?: boolean) => { + if ((force || --iconifyingCount === 0) && this._iconifyBatch) { + if (this._deleteAfterIconify) { + views.forEach(iconView => iconView.props.removeDocument?.(iconView.props.Document)); + SelectionManager.DeselectAll(); + } this._iconifyBatch?.end(); this._iconifyBatch = undefined; } - } - if (!this._deleteAfterIconify) views.forEach(dv => dv.iconify(finished)); - else if (force) finished(); + }); + if (force) finished(force); + else if (!this._deleteAfterIconify) views.forEach(dv => dv.iconify(finished)); } } onMaximizeDown = (e: React.PointerEvent) => { @@ -530,7 +531,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P left: bounds.x - this._resizeBorderWidth / 2, top: bounds.y - this._resizeBorderWidth / 2 - this._titleHeight, }}> - {!canDelete ? <div /> : topBtn("close", this.hasIcons ? "times" : "window-maximize", undefined, e => this.onCloseClick(), "Close")} + {!canDelete ? <div /> : topBtn("close", this.hasIcons ? "times" : "window-maximize", undefined, e => this.onCloseClick(this.hasIcons), "Close")} {titleArea} {!canOpen ? (null) : topBtn("open", "external-link-alt", this.onMaximizeDown, undefined, "Open in Tab (ctrl: as alias, shift: in new collection)")} {hideResizers ? (null) : |