Show a tile at beginning of visible history (#5887)

This commit is contained in:
Robin 2022-01-20 04:51:31 -05:00 committed by GitHub
parent c4fc20018d
commit f59ea6d7ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 4 deletions

View file

@ -0,0 +1,47 @@
/*
Copyright 2021 Robin Townsend <robin@robin.town>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { useContext } from "react";
import { EventTimeline } from "matrix-js-sdk/src/models/event-timeline";
import EventTileBubble from "../messages/EventTileBubble";
import RoomContext from "../../../contexts/RoomContext";
import { _t } from "../../../languageHandler";
const HistoryTile = () => {
const { room } = useContext(RoomContext);
const oldState = room.getLiveTimeline().getState(EventTimeline.BACKWARDS);
const encryptionState = oldState.getStateEvents("m.room.encryption")[0];
const historyState = oldState.getStateEvents("m.room.history_visibility")[0]?.getContent().history_visibility;
let subtitle;
if (historyState == "invited") {
subtitle = _t("You don't have permission to view messages from before you were invited.");
} else if (historyState == "joined") {
subtitle = _t("You don't have permission to view messages from before you joined.");
} else if (encryptionState) {
subtitle = _t("Encrypted messages before this point are unavailable.");
}
return <EventTileBubble
className="mx_HistoryTile"
title={_t("You can't see earlier messages")}
subtitle={subtitle}
/>;
};
export default HistoryTile;