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

Show a tile at beginning of visible history #5887

Merged
merged 27 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b15c6cb
Show date separator at beginning of timeline with hidden undecryptable
robintown Apr 25, 2021
6430168
Factor resuable RoomIntro out of NewRoomIntro
robintown Apr 25, 2021
0063fd2
Show room intro at beginning of visible history
robintown Apr 25, 2021
a2c8907
Merge branch 'develop' into room-history-intro
robintown Apr 25, 2021
0592435
Don't need 2020 in copyright
robintown May 4, 2021
98fbb7c
Check history visibility before encryption in room history intro
robintown May 4, 2021
cff6f4d
Consolidate room intro message and button code
robintown May 4, 2021
2a561c1
Merge branch 'develop' into room-history-intro
robintown May 4, 2021
cb7506f
Merge branch 'develop' into room-history-intro
robintown May 24, 2021
a68d180
Merge branch 'develop' into room-history-intro
robintown Jun 12, 2021
721693c
Consistently rename NewRoomIntro things to RoomIntro
robintown Jun 12, 2021
ee83103
Make myself the copyright holder for room history intro code
robintown Jun 12, 2021
e1c7ee0
Fix i18n strings
robintown Jun 12, 2021
272b68f
Merge branch 'develop' into room-history-intro
robintown Jun 23, 2021
cf01987
Merge branch 'develop' into room-history-intro
robintown Jul 11, 2021
d65ae77
Merge branch 'develop' into room-history-intro
robintown Jul 21, 2021
9ea373b
Fix lints
robintown Jul 21, 2021
3ef6675
Merge branch 'develop' into room-history-intro
robintown Jul 24, 2021
160277c
Merge branch 'develop' into room-history-intro
robintown Aug 6, 2021
5ae4836
Merge branch 'develop' into room-history-intro
robintown Aug 26, 2021
d0b134c
Merge branch 'develop' into room-history-intro
robintown Sep 3, 2021
d2fe79e
Merge branch 'develop' into room-history-intro
robintown Sep 18, 2021
62a7f5a
Merge branch 'develop' into room-history-intro
robintown Oct 22, 2021
1dc47b8
Merge branch 'develop' into room-history-intro
robintown Oct 25, 2021
7d1c362
Merge branch 'develop' into room-history-intro
robintown Nov 25, 2021
eba604c
Merge branch 'develop' into room-history-intro
robintown Dec 17, 2021
68ef007
Convert room history notice to a tile
robintown Dec 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions res/css/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
@import "./views/rooms/_EventBubbleTile.scss";
@import "./views/rooms/_EventTile.scss";
@import "./views/rooms/_GroupLayout.scss";
@import "./views/rooms/_HistoryTile.scss";
@import "./views/rooms/_IRCLayout.scss";
@import "./views/rooms/_JumpToBottomButton.scss";
@import "./views/rooms/_LinkPreviewGroup.scss";
Expand Down
20 changes: 20 additions & 0 deletions res/css/views/rooms/_HistoryTile.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
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.
*/

.mx_HistoryTile::before {
background-color: $header-panel-text-primary-color;
mask-image: url('$(res)/img/element-icons/hide.svg');
}
13 changes: 10 additions & 3 deletions src/components/structures/MessagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { hasText } from "../../TextForEvent";
import IRCTimelineProfileResizer from "../views/elements/IRCTimelineProfileResizer";
import DMRoomMap from "../../utils/DMRoomMap";
import NewRoomIntro from "../views/rooms/NewRoomIntro";
import HistoryTile from "../views/rooms/HistoryTile";
import { replaceableComponent } from "../../utils/replaceableComponent";
import defaultDispatcher from '../../dispatcher/dispatcher';
import CallEventGrouper from "./CallEventGrouper";
Expand Down Expand Up @@ -129,8 +130,8 @@ interface IProps {
// for pending messages.
ourUserId?: string;

// true to suppress the date at the start of the timeline
suppressFirstDateSeparator?: boolean;
// whether the timeline can visually go back any further
canBackPaginate?: boolean;

// whether to show read receipts
showReadReceipts?: boolean;
Expand Down Expand Up @@ -810,7 +811,7 @@ export default class MessagePanel extends React.Component<IProps, IState> {
if (prevEvent == null) {
// first event in the panel: depends if we could back-paginate from
// here.
return !this.props.suppressFirstDateSeparator;
return !this.props.canBackPaginate;
}
return wantsDateSeparator(prevEvent.getDate(), nextEventDate);
}
Expand Down Expand Up @@ -1352,6 +1353,12 @@ class MemberGrouper extends BaseGrouper {
eventTiles = null;
}

// If a membership event is the start of visible history, tell the user
// why they can't see earlier messages
if (!this.panel.props.canBackPaginate && !this.prevEvent) {
ret.push(<HistoryTile key="historytile" />);
}

ret.push(
<MemberEventListSummary
key={key}
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/TimelinePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
highlightedEventId={this.props.highlightedEventId}
readMarkerEventId={this.state.readMarkerEventId}
readMarkerVisible={this.state.readMarkerVisible}
suppressFirstDateSeparator={this.state.canBackPaginate}
canBackPaginate={this.state.canBackPaginate && this.state.firstVisibleEventIndex === 0}
showUrlPreview={this.props.showUrlPreview}
showReadReceipts={this.props.showReadReceipts}
ourUserId={MatrixClientPeg.get().credentials.userId}
Expand Down
47 changes: 47 additions & 0 deletions src/components/views/rooms/HistoryTile.tsx
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,10 @@
"Encrypting your message...": "Encrypting your message...",
"Your message was sent": "Your message was sent",
"Failed to send": "Failed to send",
"You don't have permission to view messages from before you were invited.": "You don't have permission to view messages from before you were invited.",
"You don't have permission to view messages from before you joined.": "You don't have permission to view messages from before you joined.",
"Encrypted messages before this point are unavailable.": "Encrypted messages before this point are unavailable.",
"You can't see earlier messages": "You can't see earlier messages",
"Scroll to most recent messages": "Scroll to most recent messages",
"Show %(count)s other previews|other": "Show %(count)s other previews",
"Show %(count)s other previews|one": "Show %(count)s other preview",
Expand Down