Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 2166331

Browse files
committed
Minor touchups to the dialog
1 parent ddd8bdc commit 2166331

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/components/views/dialogs/ModalWidgetDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
ModalButtonKind,
3232
Widget,
3333
WidgetApiFromWidgetAction,
34+
WidgetKind,
3435
} from "matrix-widget-api";
3536
import {StopGapWidgetDriver} from "../../../stores/widgets/StopGapWidgetDriver";
3637
import {MatrixClientPeg} from "../../../MatrixClientPeg";
@@ -72,7 +73,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
7273
}
7374

7475
public componentDidMount() {
75-
const driver = new StopGapWidgetDriver( [], this.widget.type);
76+
const driver = new StopGapWidgetDriver( [], this.widget, WidgetKind.Modal);
7677
const messaging = new ClientWidgetApi(this.widget, this.appFrame.current, driver);
7778
this.setState({messaging});
7879
}

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
570570
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
571571
"%(names)s and %(lastPerson)s are typing …": "%(names)s and %(lastPerson)s are typing …",
572-
"Remain on your screen when you leave this room (when running)": "Remain on your screen when you leave this room (when running)",
572+
"Remain on your screen when viewing another room, when running": "Remain on your screen when viewing another room, when running",
573573
"Remain on your screen while running": "Remain on your screen while running",
574574
"Send stickers into this room": "Send stickers into this room",
575575
"Send stickers into your active room": "Send stickers into your active room",

src/stores/widgets/StopGapWidget.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
WidgetApiFromWidgetAction,
3535
IModalWidgetOpenRequest,
3636
IWidgetApiErrorResponseData,
37+
WidgetKind,
3738
} from "matrix-widget-api";
3839
import { StopGapWidgetDriver } from "./StopGapWidgetDriver";
3940
import { EventEmitter } from "events";
@@ -152,6 +153,7 @@ export class StopGapWidget extends EventEmitter {
152153
private mockWidget: ElementWidget;
153154
private scalarToken: string;
154155
private roomId?: string;
156+
private kind: WidgetKind;
155157

156158
constructor(private appTileProps: IAppTileProps) {
157159
super();
@@ -165,6 +167,7 @@ export class StopGapWidget extends EventEmitter {
165167

166168
this.mockWidget = new ElementWidget(app);
167169
this.roomId = appTileProps.room?.roomId;
170+
this.kind = appTileProps.userWidget ? WidgetKind.Account : WidgetKind.Room; // probably
168171
}
169172

170173
private get eventListenerRoomId(): string {
@@ -303,7 +306,7 @@ export class StopGapWidget extends EventEmitter {
303306
public start(iframe: HTMLIFrameElement) {
304307
if (this.started) return;
305308
const allowedCapabilities = this.appTileProps.whitelistCapabilities || [];
306-
const driver = new StopGapWidgetDriver( allowedCapabilities, this.mockWidget);
309+
const driver = new StopGapWidgetDriver( allowedCapabilities, this.mockWidget, this.kind);
307310
this.messaging = new ClientWidgetApi(this.mockWidget, iframe, driver);
308311
this.messaging.on("preparing", () => this.emit("preparing"));
309312
this.messaging.on("ready", () => this.emit("ready"));

src/stores/widgets/StopGapWidgetDriver.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
import {
1818
Capability,
1919
ISendEventDetails,
20-
MatrixCapabilities, Widget,
20+
MatrixCapabilities,
21+
Widget,
2122
WidgetDriver,
23+
WidgetKind,
2224
} from "matrix-widget-api";
2325
import { iterableDiff, iterableUnion } from "../../utils/iterables";
2426
import { MatrixClientPeg } from "../../MatrixClientPeg";
@@ -31,7 +33,8 @@ import WidgetCapabilitiesPromptDialog, { getRememberedCapabilitiesForWidget } fr
3133
export class StopGapWidgetDriver extends WidgetDriver {
3234
private allowedCapabilities: Set<Capability>;
3335

34-
constructor(allowedCapabilities: Capability[], private forWidget: Widget) {
36+
// TODO: Refactor widgetKind into the Widget class
37+
constructor(allowedCapabilities: Capability[], private forWidget: Widget, private forWidgetKind: WidgetKind) {
3538
super();
3639

3740
// Always allow screenshots to be taken because it's a client-induced flow. The widget can't
@@ -57,6 +60,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
5760
{
5861
requestedCapabilities: missing,
5962
widget: this.forWidget,
63+
widgetKind: this.forWidgetKind,
6064
}).finished;
6165
(result.approved || []).forEach(cap => allowedSoFar.add(cap));
6266
} catch (e) {

src/widgets/CapabilityText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface TranslatedCapabilityText {
5050
export class CapabilityText {
5151
private static simpleCaps: IStaticCapText = {
5252
[MatrixCapabilities.AlwaysOnScreen]: {
53-
[WidgetKind.Room]: _td("Remain on your screen when you leave this room (when running)"),
53+
[WidgetKind.Room]: _td("Remain on your screen when viewing another room, when running"),
5454
[GENERIC_WIDGET_KIND]: _td("Remain on your screen while running"),
5555
},
5656
[MatrixCapabilities.StickerSending]: {

0 commit comments

Comments
 (0)