From 38962560acce8fdb09705eee3590ae5331028eea Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 28 Apr 2020 02:18:43 +0300 Subject: [PATCH] Style fixes Signed-off-by: Pauli Virtanen --- src/components/views/elements/AppTile.js | 11 ++++++----- src/widgets/WidgetApi.ts | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index f5664fd613..ef0075e800 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -39,6 +39,7 @@ import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore"; import {aboveLeftOf, ContextMenu, ContextMenuButton} from "../../structures/ContextMenu"; import PersistedElement from "./PersistedElement"; import {WidgetType} from "../../../widgets/WidgetType"; +import {Capability} from "../../../widgets/WidgetApi"; import {sleep} from "../../../utils/promise"; const ALLOWED_APP_URL_SCHEMES = ['https:', 'http:']; @@ -344,18 +345,18 @@ export default class AppTile extends React.Component { * @returns {Promise<*>} Resolves when the widget is terminated, or timeout passed. */ _endWidgetActions() { - let promise; + let terminationPromise; - if (this._hasCapability('im.vector.receive_terminate')) { + if (this._hasCapability(Capability.ReceiveTerminate)) { // Wait for widget to terminate within a timeout const timeout = 2000; const messaging = ActiveWidgetStore.getWidgetMessaging(this.props.app.id); - promise = Promise.race([messaging.terminate(), sleep(timeout)]); + terminationPromise = Promise.race([messaging.terminate(), sleep(timeout)]); } else { - promise = Promise.resolve(); + terminationPromise = Promise.resolve(); } - return promise.finally(() => { + return terminationPromise.finally(() => { // 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 // stream open, even after death. See https://github.com/vector-im/riot-web/issues/7351 diff --git a/src/widgets/WidgetApi.ts b/src/widgets/WidgetApi.ts index c5420dca38..795c6648ef 100644 --- a/src/widgets/WidgetApi.ts +++ b/src/widgets/WidgetApi.ts @@ -111,11 +111,12 @@ export class WidgetApi extends EventEmitter { } else if (payload.action === KnownWidgetActions.Terminate) { // Finalization needs to be async, so postpone with a promise let finalizePromise = Promise.resolve(); - const wait = promise => { + const wait = (promise) => { finalizePromise = finalizePromise.then(value => promise); - } + }; this.emit('terminate', wait); Promise.resolve(finalizePromise).then(() => { + // Acknowledge that we're shut down now this.replyToRequest(payload, {}); }); } else {