Skip to content

Commit 47dfae5

Browse files
authored
Revert "Fix widgets getting stuck in loading states (#31314)"
This reverts commit 71895a3.
1 parent 9faee16 commit 47dfae5

26 files changed

Lines changed: 804 additions & 1240 deletions

playwright/e2e/voip/element-call.spec.ts

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -544,37 +544,34 @@ test.describe("Element Call", () => {
544544
});
545545

546546
// For https://github.com/element-hq/element-web/issues/30838
547-
test("should be able to join a call, leave via PiP, and rejoin the call", async ({
548-
page,
549-
user,
550-
room,
551-
app,
552-
bot,
553-
}) => {
554-
await app.viewRoomById(room.roomId);
555-
await expect(page.getByText("Bob and one other were invited and joined")).toBeVisible();
556-
await app.client.setPowerLevel(room.roomId, bot.credentials.userId, 50);
547+
test.fail(
548+
"should be able to join a call, leave via PiP, and rejoin the call",
549+
async ({ page, user, room, app, bot }) => {
550+
await app.viewRoomById(room.roomId);
551+
await expect(page.getByText("Bob and one other were invited and joined")).toBeVisible();
552+
await app.client.setPowerLevel(room.roomId, bot.credentials.userId, 50);
557553

558-
await sendRTCState(bot, room.roomId);
559-
await openAndJoinCall(page, true);
554+
await sendRTCState(bot, room.roomId);
555+
await openAndJoinCall(page, true);
560556

561-
await app.viewRoomByName("OtherRoom");
562-
const pipContainer = page.locator(".mx_WidgetPip");
557+
await app.viewRoomByName("OtherRoom");
558+
const pipContainer = page.locator(".mx_WidgetPip");
563559

564-
// We should have a PiP container here.
565-
await expect(pipContainer).toBeVisible();
560+
// We should have a PiP container here.
561+
await expect(pipContainer).toBeVisible();
566562

567-
// Leave the call.
568-
const overlay = page.locator(".mx_WidgetPip_overlay");
569-
await overlay.hover({ timeout: 2000 }); // Show the call footer.
570-
await overlay.getByRole("button", { name: "Leave", exact: true }).click();
563+
// Leave the call.
564+
const overlay = page.locator(".mx_WidgetPip_overlay");
565+
await overlay.hover({ timeout: 2000 }); // Show the call footer.
566+
await overlay.getByRole("button", { name: "Leave", exact: true }).click();
571567

572-
// PiP container goes.
573-
await expect(pipContainer).not.toBeVisible();
568+
// PiP container goes.
569+
await expect(pipContainer).not.toBeVisible();
574570

575-
// Rejoin the call
576-
await app.viewRoomById(room.roomId);
577-
await openAndJoinCall(page, true);
578-
});
571+
// Rejoin the call
572+
await app.viewRoomById(room.roomId);
573+
await openAndJoinCall(page, true);
574+
},
575+
);
579576
});
580577
});

src/LegacyCallHandler.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,9 @@ export default class LegacyCallHandler extends TypedEventEmitter<LegacyCallHandl
10551055
const jitsiWidgets = roomInfo.widgets.filter((w) => WidgetType.JITSI.matches(w.type));
10561056
jitsiWidgets.forEach((w) => {
10571057
const messaging = WidgetMessagingStore.instance.getMessagingForUid(WidgetUtils.getWidgetUid(w));
1058-
if (!messaging?.widgetApi) return; // more "should never happen" words
1058+
if (!messaging) return; // more "should never happen" words
10591059

1060-
messaging.widgetApi.transport.send(ElementWidgetActions.HangupCall, {});
1060+
messaging.transport.send(ElementWidgetActions.HangupCall, {});
10611061
});
10621062
}
10631063

src/Livestream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ async function createLiveStream(matrixClient: MatrixClient, roomId: string): Pro
4141

4242
export async function startJitsiAudioLivestream(
4343
matrixClient: MatrixClient,
44-
widgetApi: ClientWidgetApi,
44+
widgetMessaging: ClientWidgetApi,
4545
roomId: string,
4646
): Promise<void> {
4747
const streamId = await createLiveStream(matrixClient, roomId);
4848

49-
await widgetApi.transport.send(ElementWidgetActions.StartLiveStream, {
49+
await widgetMessaging.transport.send(ElementWidgetActions.StartLiveStream, {
5050
rtmpStreamKey: AUDIOSTREAM_DUMMY_URL + streamId,
5151
});
5252
}

src/components/views/context_menus/WidgetContextMenu.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import React, { type JSX, type ComponentProps, useContext } from "react";
10-
import { type IWidget, MatrixCapabilities } from "matrix-widget-api";
10+
import { type ClientWidgetApi, type IWidget, MatrixCapabilities } from "matrix-widget-api";
1111
import { logger } from "matrix-js-sdk/src/logger";
1212
import { type ApprovalOpts, WidgetLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/WidgetLifecycle";
1313
import { type MatrixClient, type Room } from "matrix-js-sdk/src/matrix";
@@ -28,7 +28,7 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
2828
import { Container, WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
2929
import { getConfigLivestreamUrl, startJitsiAudioLivestream } from "../../../Livestream";
3030
import { ModuleRunner } from "../../../modules/ModuleRunner";
31-
import { ElementWidget, type WidgetMessaging } from "../../../stores/widgets/WidgetMessaging";
31+
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
3232
import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx";
3333

3434
interface IProps extends Omit<ComponentProps<typeof IconizedContextMenu>, "children"> {
@@ -69,10 +69,10 @@ const showDeleteButton = (canModify: boolean, onDeleteClick: undefined | (() =>
6969
return !!onDeleteClick || canModify;
7070
};
7171

72-
const showSnapshotButton = (widgetMessaging: WidgetMessaging | undefined): boolean => {
72+
const showSnapshotButton = (widgetMessaging: ClientWidgetApi | undefined): boolean => {
7373
return (
7474
SettingsStore.getValue("enableWidgetScreenshots") &&
75-
!!widgetMessaging?.widgetApi?.hasCapability(MatrixCapabilities.Screenshots)
75+
!!widgetMessaging?.hasCapability(MatrixCapabilities.Screenshots)
7676
);
7777
};
7878

@@ -123,7 +123,7 @@ export const WidgetContextMenu: React.FC<IProps> = ({
123123
if (roomId && showStreamAudioStreamButton(app)) {
124124
const onStreamAudioClick = async (): Promise<void> => {
125125
try {
126-
await startJitsiAudioLivestream(cli, widgetMessaging!.widgetApi!, roomId);
126+
await startJitsiAudioLivestream(cli, widgetMessaging!, roomId);
127127
} catch (err) {
128128
logger.error("Failed to start livestream", err);
129129
// XXX: won't i18n well, but looks like widget api only support 'message'?
@@ -161,7 +161,7 @@ export const WidgetContextMenu: React.FC<IProps> = ({
161161
let snapshotButton: JSX.Element | undefined;
162162
if (showSnapshotButton(widgetMessaging)) {
163163
const onSnapshotClick = (): void => {
164-
widgetMessaging?.widgetApi
164+
widgetMessaging
165165
?.takeScreenshot()
166166
.then((data) => {
167167
dis.dispatch({

src/components/views/dialogs/ModalWidgetDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import { ErrorIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
2727
import BaseDialog from "./BaseDialog";
2828
import { _t, getUserLanguage } from "../../../languageHandler";
2929
import AccessibleButton, { type AccessibleButtonKind } from "../elements/AccessibleButton";
30-
import { ElementWidgetDriver } from "../../../stores/widgets/ElementWidgetDriver";
30+
import { StopGapWidgetDriver } from "../../../stores/widgets/StopGapWidgetDriver";
3131
import { MatrixClientPeg } from "../../../MatrixClientPeg";
3232
import { OwnProfileStore } from "../../../stores/OwnProfileStore";
3333
import { arrayFastClone } from "../../../utils/arrays";
34-
import { ElementWidget } from "../../../stores/widgets/WidgetMessaging";
34+
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
3535
import { ELEMENT_CLIENT_ID } from "../../../identifiers";
3636
import ThemeWatcher, { ThemeWatcherEvent } from "../../../settings/watchers/ThemeWatcher";
3737

@@ -72,7 +72,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
7272
}
7373

7474
public componentDidMount(): void {
75-
const driver = new ElementWidgetDriver(this.widget, WidgetKind.Modal, false);
75+
const driver = new StopGapWidgetDriver([], this.widget, WidgetKind.Modal, false);
7676
const messaging = new ClientWidgetApi(this.widget, this.appFrame.current!, driver);
7777
this.setState({ messaging });
7878
}

0 commit comments

Comments
 (0)