Files
arduino-ide/arduino-ide-extension/src/browser/theia/dialogs/dialogs.tsx
Akos Kitta 69ae38effa feat: simplify board and port handling (#2165)
Use Arduino CLI revision `38479dc`

Closes #43
Closes #82
Closes #1319
Closes #1366
Closes #2143
Closes #2158

Ref: 38479dc706

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
2023-08-18 14:42:50 +02:00

46 lines
1.7 KiB
TypeScript

import {
AbstractDialog as TheiaAbstractDialog,
DialogProps,
} from '@theia/core/lib/browser/dialogs';
import { ReactDialog as TheiaReactDialog } from '@theia/core/lib/browser/dialogs/react-dialog';
import { codiconArray } from '@theia/core/lib/browser/widgets/widget';
import type { Message } from '@theia/core/shared/@phosphor/messaging';
import { inject, injectable } from '@theia/core/shared/inversify';
@injectable()
export abstract class AbstractDialog<T> extends TheiaAbstractDialog<T> {
constructor(
@inject(DialogProps) protected override readonly props: DialogProps
) {
super(props);
this.closeCrossNode.classList.remove(...codiconArray('close'));
this.closeCrossNode.classList.add('fa', 'fa-close');
}
}
@injectable()
export abstract class ReactDialog<T> extends TheiaReactDialog<T> {
private _isOnCloseRequestInProgress = false;
override dispose(): void {
// There is a bug in Theia, and the React component's `componentWillUnmount` will not be called, as the Theia widget is already disposed when closing and reopening a dialog.
// Widget lifecycle issue in Theia: https://github.com/eclipse-theia/theia/issues/12093
// Bogus react widget lifecycle management PR: https://github.com/eclipse-theia/theia/pull/11687
// Do not call super. Do not let the Phosphor widget to be disposed on dialog close.
if (this._isOnCloseRequestInProgress) {
// Do not let the widget dispose on close.
return;
}
super.dispose();
}
protected override onCloseRequest(message: Message): void {
this._isOnCloseRequestInProgress = true;
try {
super.onCloseRequest(message);
} finally {
this._isOnCloseRequestInProgress = false;
}
}
}