2020-09-16 12:38:47 -06:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2020-09-16 12:38:47 -06:00
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-09-16 12:38:47 -06:00
|
|
|
*/
|
|
|
|
|
|
2025-03-27 10:43:58 +00:00
|
|
|
import React, { type JSX } from "react";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type MatrixEvent } from "matrix-js-sdk/src/matrix";
|
2026-01-05 17:14:51 +00:00
|
|
|
import { VideoCallSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
2026-02-03 15:37:57 +01:00
|
|
|
import { EventTileBubble } from "@element-hq/web-shared-components";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2020-09-16 12:38:47 -06:00
|
|
|
import { _t } from "../../../languageHandler";
|
2020-09-16 14:59:15 -06:00
|
|
|
import WidgetStore from "../../../stores/WidgetStore";
|
2021-01-18 20:26:47 -07:00
|
|
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
2026-03-13 13:44:18 +00:00
|
|
|
import { WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
|
2020-09-16 12:38:47 -06:00
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
mxEvent: MatrixEvent;
|
2022-01-25 13:10:17 +00:00
|
|
|
timestamp?: JSX.Element;
|
2020-09-16 12:38:47 -06:00
|
|
|
}
|
|
|
|
|
|
2020-09-16 14:59:40 -06:00
|
|
|
export default class MJitsiWidgetEvent extends React.PureComponent<IProps> {
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2020-09-16 12:38:47 -06:00
|
|
|
const url = this.props.mxEvent.getContent()["url"];
|
|
|
|
|
const prevUrl = this.props.mxEvent.getPrevContent()["url"];
|
|
|
|
|
const senderName = this.props.mxEvent.sender?.name || this.props.mxEvent.getSender();
|
2023-06-15 08:46:19 +01:00
|
|
|
const room = MatrixClientPeg.safeGet().getRoom(this.props.mxEvent.getRoomId());
|
2023-03-29 08:22:35 +01:00
|
|
|
if (!room) return null;
|
2021-01-18 20:26:47 -07:00
|
|
|
const widgetId = this.props.mxEvent.getStateKey();
|
2021-01-27 14:40:04 -07:00
|
|
|
const widget = WidgetStore.instance.getRoom(room.roomId, true).widgets.find((w) => w.id === widgetId);
|
2020-09-16 12:38:47 -06:00
|
|
|
|
2023-10-02 13:52:27 +01:00
|
|
|
let joinCopy: string | null = _t("timeline|m.widget|jitsi_join_top_prompt");
|
2026-03-13 13:44:18 +00:00
|
|
|
if (widget && WidgetLayoutStore.instance.isInContainer(room, widget, "right")) {
|
2023-10-02 13:52:27 +01:00
|
|
|
joinCopy = _t("timeline|m.widget|jitsi_join_right_prompt");
|
2021-01-27 14:40:04 -07:00
|
|
|
} else if (!widget) {
|
|
|
|
|
joinCopy = null;
|
2020-09-16 14:59:15 -06:00
|
|
|
}
|
|
|
|
|
|
2020-09-16 12:38:47 -06:00
|
|
|
if (!url) {
|
|
|
|
|
// removed
|
2020-11-04 17:00:07 +00:00
|
|
|
return (
|
|
|
|
|
<EventTileBubble
|
2026-01-05 17:14:51 +00:00
|
|
|
icon={<VideoCallSolidIcon />}
|
2026-02-03 15:37:57 +01:00
|
|
|
className="mx_EventTileBubble mx_MJitsiWidgetEvent"
|
2023-10-02 13:52:27 +01:00
|
|
|
title={_t("timeline|m.widget|jitsi_ended", { senderName })}
|
2026-02-03 15:37:57 +01:00
|
|
|
>
|
|
|
|
|
{this.props.timestamp}
|
|
|
|
|
</EventTileBubble>
|
2020-11-04 17:00:07 +00:00
|
|
|
);
|
2020-09-16 12:38:47 -06:00
|
|
|
} else if (prevUrl) {
|
|
|
|
|
// modified
|
2020-11-04 17:00:07 +00:00
|
|
|
return (
|
|
|
|
|
<EventTileBubble
|
2026-01-05 17:14:51 +00:00
|
|
|
icon={<VideoCallSolidIcon />}
|
2026-02-03 15:37:57 +01:00
|
|
|
className="mx_EventTileBubble mx_MJitsiWidgetEvent"
|
2023-10-02 13:52:27 +01:00
|
|
|
title={_t("timeline|m.widget|jitsi_updated", { senderName })}
|
2020-11-04 17:00:07 +00:00
|
|
|
subtitle={joinCopy}
|
2026-02-03 15:37:57 +01:00
|
|
|
>
|
|
|
|
|
{this.props.timestamp}
|
|
|
|
|
</EventTileBubble>
|
2020-11-04 17:00:07 +00:00
|
|
|
);
|
2020-09-16 12:38:47 -06:00
|
|
|
} else {
|
|
|
|
|
// assume added
|
2020-11-04 17:00:07 +00:00
|
|
|
return (
|
|
|
|
|
<EventTileBubble
|
2026-01-05 17:14:51 +00:00
|
|
|
icon={<VideoCallSolidIcon />}
|
2026-02-03 15:37:57 +01:00
|
|
|
className="mx_EventTileBubble mx_MJitsiWidgetEvent"
|
2023-10-02 13:52:27 +01:00
|
|
|
title={_t("timeline|m.widget|jitsi_started", { senderName })}
|
2020-11-04 17:00:07 +00:00
|
|
|
subtitle={joinCopy}
|
2026-02-03 15:37:57 +01:00
|
|
|
>
|
|
|
|
|
{this.props.timestamp}
|
|
|
|
|
</EventTileBubble>
|
2020-11-04 17:00:07 +00:00
|
|
|
);
|
2020-09-16 12:38:47 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|