2022-01-20 04:51:31 -05:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-01-20 04:51:31 -05:00
|
|
|
Copyright 2021 Robin Townsend <robin@robin.town>
|
|
|
|
|
|
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.
|
2022-01-20 04:51:31 -05:00
|
|
|
*/
|
|
|
|
|
|
2024-12-02 09:49:52 +00:00
|
|
|
import React from "react";
|
2023-08-08 08:16:04 +01:00
|
|
|
import { EventTimeline } from "matrix-js-sdk/src/matrix";
|
2022-01-20 04:51:31 -05:00
|
|
|
|
|
|
|
|
import EventTileBubble from "../messages/EventTileBubble";
|
|
|
|
|
import { _t } from "../../../languageHandler";
|
2024-12-02 09:49:52 +00:00
|
|
|
import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx";
|
2022-01-20 04:51:31 -05:00
|
|
|
|
2023-01-12 13:25:14 +00:00
|
|
|
const HistoryTile: React.FC = () => {
|
2024-12-02 09:49:52 +00:00
|
|
|
const { room } = useScopedRoomContext("room");
|
2022-01-20 04:51:31 -05:00
|
|
|
|
2023-03-13 15:07:20 +00:00
|
|
|
const oldState = room?.getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
|
|
|
|
const historyState = oldState?.getStateEvents("m.room.history_visibility")[0]?.getContent().history_visibility;
|
2022-01-20 04:51:31 -05:00
|
|
|
|
2023-03-13 15:07:20 +00:00
|
|
|
let subtitle: string | undefined;
|
2022-01-20 04:51:31 -05:00
|
|
|
if (historyState == "invited") {
|
2023-09-14 18:47:29 +01:00
|
|
|
subtitle = _t("timeline|no_permission_messages_before_invite");
|
2022-01-20 04:51:31 -05:00
|
|
|
} else if (historyState == "joined") {
|
2023-09-14 18:47:29 +01:00
|
|
|
subtitle = _t("timeline|no_permission_messages_before_join");
|
2022-01-20 04:51:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2023-09-14 18:47:29 +01:00
|
|
|
<EventTileBubble
|
|
|
|
|
className="mx_HistoryTile"
|
|
|
|
|
title={_t("timeline|historical_messages_unavailable")}
|
|
|
|
|
subtitle={subtitle}
|
|
|
|
|
/>
|
2022-01-20 04:51:31 -05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default HistoryTile;
|