Minimize widget immediately, and end it later
Signed-off-by: Pauli Virtanen <pav@iki.fi>pull/21833/head
parent
4fac781051
commit
94745e9407
|
@ -39,6 +39,7 @@ import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
|
||||||
import {aboveLeftOf, ContextMenu, ContextMenuButton} from "../../structures/ContextMenu";
|
import {aboveLeftOf, ContextMenu, ContextMenuButton} from "../../structures/ContextMenu";
|
||||||
import PersistedElement from "./PersistedElement";
|
import PersistedElement from "./PersistedElement";
|
||||||
import {WidgetType} from "../../../widgets/WidgetType";
|
import {WidgetType} from "../../../widgets/WidgetType";
|
||||||
|
import {sleep} from "../../../utils/promise";
|
||||||
|
|
||||||
const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:'];
|
const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:'];
|
||||||
const ENABLE_REACT_PERF = false;
|
const ENABLE_REACT_PERF = false;
|
||||||
|
@ -344,10 +345,9 @@ export default class AppTile extends React.Component {
|
||||||
*/
|
*/
|
||||||
_endWidgetActions() {
|
_endWidgetActions() {
|
||||||
const timeout = 2000;
|
const timeout = 2000;
|
||||||
const timeoutPromise = new Promise(resolve => setTimeout(resolve, timeout));
|
|
||||||
const messaging = ActiveWidgetStore.getWidgetMessaging(this.props.app.id);
|
const messaging = ActiveWidgetStore.getWidgetMessaging(this.props.app.id);
|
||||||
|
|
||||||
return Promise.race([messaging.terminate(), timeoutPromise]).finally(() => {
|
return Promise.race([messaging.terminate(), sleep(timeout)]).finally(() => {
|
||||||
// HACK: This is a really dirty way to ensure that Jitsi cleans up
|
// HACK: This is a really dirty way to ensure that Jitsi cleans up
|
||||||
// its hold on the webcam. Without this, the widget holds a media
|
// its hold on the webcam. Without this, the widget holds a media
|
||||||
// stream open, even after death. See https://github.com/vector-im/riot-web/issues/7351
|
// stream open, even after death. See https://github.com/vector-im/riot-web/issues/7351
|
||||||
|
@ -552,18 +552,13 @@ export default class AppTile extends React.Component {
|
||||||
if (this.props.userWidget) {
|
if (this.props.userWidget) {
|
||||||
this._onMinimiseClick();
|
this._onMinimiseClick();
|
||||||
} else {
|
} else {
|
||||||
let promise;
|
|
||||||
if (this.props.show) {
|
if (this.props.show) {
|
||||||
// if we were being shown, end the widget as we're about to be minimized.
|
// if we were being shown, end the widget as we're about to be minimized.
|
||||||
promise = this._endWidgetActions();
|
this._endWidgetActions();
|
||||||
} else {
|
|
||||||
promise = Promise.resolve();
|
|
||||||
}
|
}
|
||||||
promise.then(() => {
|
dis.dispatch({
|
||||||
dis.dispatch({
|
action: 'appsDrawer',
|
||||||
action: 'appsDrawer',
|
show: !this.props.show,
|
||||||
show: !this.props.show,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue