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

Commit 2b8e709

Browse files
authored
Merge pull request #6369 from matrix-org/travis/tileshape
Use TileShape enum more universally
2 parents 181a23d + 9b64959 commit 2b8e709

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

src/components/views/elements/ReplyThread.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
Copyright 2017 New Vector Ltd
2+
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
33
Copyright 2019 Michael Telatynski <[email protected]>
4-
Copyright 2019 The Matrix.org Foundation C.I.C.
54
65
Licensed under the Apache License, Version 2.0 (the "License");
76
you may not use this file except in compliance with the License.
@@ -32,6 +31,7 @@ import sanitizeHtml from "sanitize-html";
3231
import { UIFeature } from "../../../settings/UIFeature";
3332
import { PERMITTED_URL_SCHEMES } from "../../../HtmlUtils";
3433
import { replaceableComponent } from "../../../utils/replaceableComponent";
34+
import { TileShape } from "../rooms/EventTile";
3535

3636
// This component does no cycle detection, simply because the only way to make such a cycle would be to
3737
// craft event_id's, using a homeserver that generates predictable event IDs; even then the impact would
@@ -384,7 +384,7 @@ export default class ReplyThread extends React.Component {
384384
{ dateSep }
385385
<EventTile
386386
mxEvent={ev}
387-
tileShape="reply"
387+
tileShape={TileShape.Reply}
388388
onHeightChanged={this.props.onHeightChanged}
389389
permalinkCreator={this.props.permalinkCreator}
390390
isRedacted={ev.isRedacted()}

src/components/views/messages/MFileBody.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2015, 2016, 2018, 2021 The Matrix.org Foundation C.I.C.
2+
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import AccessibleButton from "../elements/AccessibleButton";
2424
import { replaceableComponent } from "../../../utils/replaceableComponent";
2525
import { mediaFromContent } from "../../../customisations/Media";
2626
import ErrorDialog from "../dialogs/ErrorDialog";
27+
import { TileShape } from "../rooms/EventTile";
2728

2829
let downloadIconUrl; // cached copy of the download.svg asset for the sandboxed iframe later on
2930

@@ -306,7 +307,7 @@ export default class MFileBody extends React.Component {
306307
// If the attachment is not encrypted then we check whether we
307308
// are being displayed in the room timeline or in a list of
308309
// files in the right hand side of the screen.
309-
if (this.props.tileShape === "file_grid") {
310+
if (this.props.tileShape === TileShape.FileGrid) {
310311
return (
311312
<span className="mx_MFileBody">
312313
{placeholder}

src/components/views/messages/MessageEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class MessageEvent extends React.Component {
4242
onHeightChanged: PropTypes.func,
4343

4444
/* the shape of the tile, used */
45-
tileShape: PropTypes.string,
45+
tileShape: PropTypes.string, // TODO: Use TileShape enum
4646

4747
/* the maximum image height to use, if the event is an image */
4848
maxImageHeight: PropTypes.number,

src/components/views/rooms/EventTile.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ export default class EventTile extends React.Component<IProps, IState> {
902902
mx_EventTile_12hr: this.props.isTwelveHour,
903903
// Note: we keep the `sending` state class for tests, not for our styles
904904
mx_EventTile_sending: !isEditing && isSending,
905-
mx_EventTile_highlight: this.props.tileShape === 'notif' ? false : this.shouldHighlight(),
905+
mx_EventTile_highlight: this.props.tileShape === TileShape.Notif ? false : this.shouldHighlight(),
906906
mx_EventTile_selected: this.props.isSelectedEvent,
907907
mx_EventTile_continuation: this.props.tileShape ? '' : this.props.continuation,
908908
mx_EventTile_last: this.props.last,
@@ -935,7 +935,7 @@ export default class EventTile extends React.Component<IProps, IState> {
935935
let avatarSize;
936936
let needsSenderProfile;
937937

938-
if (this.props.tileShape === "notif") {
938+
if (this.props.tileShape === TileShape.Notif) {
939939
avatarSize = 24;
940940
needsSenderProfile = true;
941941
} else if (tileHandler === 'messages.RoomCreate' || isBubbleMessage) {
@@ -949,7 +949,7 @@ export default class EventTile extends React.Component<IProps, IState> {
949949
} else if (this.props.layout == Layout.IRC) {
950950
avatarSize = 14;
951951
needsSenderProfile = true;
952-
} else if (this.props.continuation && this.props.tileShape !== "file_grid") {
952+
} else if (this.props.continuation && this.props.tileShape !== TileShape.FileGrid) {
953953
// no avatar or sender profile for continuation messages
954954
avatarSize = 0;
955955
needsSenderProfile = false;
@@ -979,7 +979,11 @@ export default class EventTile extends React.Component<IProps, IState> {
979979
}
980980

981981
if (needsSenderProfile) {
982-
if (!this.props.tileShape || this.props.tileShape === 'reply' || this.props.tileShape === 'reply_preview') {
982+
if (
983+
!this.props.tileShape
984+
|| this.props.tileShape === TileShape.Reply
985+
|| this.props.tileShape === TileShape.ReplyPreview
986+
) {
983987
sender = <SenderProfile onClick={this.onSenderProfileClick}
984988
mxEvent={this.props.mxEvent}
985989
enableFlair={this.props.enableFlair}
@@ -1065,7 +1069,7 @@ export default class EventTile extends React.Component<IProps, IState> {
10651069
}
10661070

10671071
switch (this.props.tileShape) {
1068-
case 'notif': {
1072+
case TileShape.Notif: {
10691073
const room = this.context.getRoom(this.props.mxEvent.getRoomId());
10701074
return React.createElement(this.props.as || "li", {
10711075
"className": classes,
@@ -1097,7 +1101,7 @@ export default class EventTile extends React.Component<IProps, IState> {
10971101
</div>,
10981102
]);
10991103
}
1100-
case 'file_grid': {
1104+
case TileShape.FileGrid: {
11011105
return React.createElement(this.props.as || "li", {
11021106
"className": classes,
11031107
"aria-live": ariaLive,
@@ -1128,10 +1132,10 @@ export default class EventTile extends React.Component<IProps, IState> {
11281132
]);
11291133
}
11301134

1131-
case 'reply':
1132-
case 'reply_preview': {
1135+
case TileShape.Reply:
1136+
case TileShape.ReplyPreview: {
11331137
let thread;
1134-
if (this.props.tileShape === 'reply_preview') {
1138+
if (this.props.tileShape === TileShape.ReplyPreview) {
11351139
thread = ReplyThread.makeThread(
11361140
this.props.mxEvent,
11371141
this.props.onHeightChanged,

src/components/views/rooms/ReplyPreview.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2017 New Vector Ltd
2+
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import PropTypes from "prop-types";
2424
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
2525
import { UIFeature } from "../../../settings/UIFeature";
2626
import { replaceableComponent } from "../../../utils/replaceableComponent";
27+
import { TileShape } from "./EventTile";
2728

2829
function cancelQuoting() {
2930
dis.dispatch({
@@ -90,7 +91,7 @@ export default class ReplyPreview extends React.Component {
9091
<div className="mx_ReplyPreview_clear" />
9192
<EventTile
9293
alwaysShowTimestamps={true}
93-
tileShape="reply_preview"
94+
tileShape={TileShape.ReplyPreview}
9495
mxEvent={this.state.event}
9596
permalinkCreator={this.props.permalinkCreator}
9697
isTwelveHour={SettingsStore.getValue("showTwelveHourTimestamps")}

0 commit comments

Comments
 (0)