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

Commit f0cf004

Browse files
authored
Merge pull request #6702 from nordeck/nic/fix/even-tile-preview
Replace fake username in EventTilePreview with a proper loading state
2 parents 3046f0e + 6a550f2 commit f0cf004

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
@import "./views/elements/_EditableItemList.scss";
133133
@import "./views/elements/_ErrorBoundary.scss";
134134
@import "./views/elements/_EventListSummary.scss";
135+
@import "./views/elements/_EventTilePreview.scss";
135136
@import "./views/elements/_FacePile.scss";
136137
@import "./views/elements/_Field.scss";
137138
@import "./views/elements/_ImageView.scss";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2021 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_EventTilePreview_loader {
18+
&.mx_IRCLayout,
19+
&.mx_GroupLayout {
20+
padding: 9px 0;
21+
}
22+
}

src/components/views/elements/EventTilePreview.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import SettingsStore from "../../../settings/SettingsStore";
2525
import { Layout } from "../../../settings/Layout";
2626
import { UIFeature } from "../../../settings/UIFeature";
2727
import { replaceableComponent } from "../../../utils/replaceableComponent";
28+
import Spinner from './Spinner';
2829

2930
interface IProps {
3031
/**
@@ -45,7 +46,7 @@ interface IProps {
4546
/**
4647
* The ID of the displayed user
4748
*/
48-
userId: string;
49+
userId?: string;
4950

5051
/**
5152
* The display name of the displayed user
@@ -118,13 +119,16 @@ export default class EventTilePreview extends React.Component<IProps, IState> {
118119
}
119120

120121
public render() {
121-
const event = this.fakeEvent(this.state);
122-
123122
const className = classnames(this.props.className, {
124123
"mx_IRCLayout": this.props.layout == Layout.IRC,
125124
"mx_GroupLayout": this.props.layout == Layout.Group,
125+
"mx_EventTilePreview_loader": !this.props.userId,
126126
});
127127

128+
if (!this.props.userId) return <div className={className}><Spinner /></div>;
129+
130+
const event = this.fakeEvent(this.state);
131+
128132
return <div className={className}>
129133
<EventTile
130134
mxEvent={event}

src/components/views/settings/LayoutSwitcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Layout } from "../../../settings/Layout";
2626
import { SettingLevel } from "../../../settings/SettingLevel";
2727

2828
interface IProps {
29-
userId: string;
29+
userId?: string;
3030
displayName: string;
3131
avatarUrl: string;
3232
messagePreviewText: string;

src/components/views/settings/tabs/user/AppearanceUserSettingsTab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface IState extends IThemeState {
6767
showAdvanced: boolean;
6868
layout: Layout;
6969
// User profile data for the message preview
70-
userId: string;
70+
userId?: string;
7171
displayName: string;
7272
avatarUrl: string;
7373
}
@@ -92,8 +92,8 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
9292
systemFont: SettingsStore.getValue("systemFont"),
9393
showAdvanced: false,
9494
layout: SettingsStore.getValue("layout"),
95-
userId: "@erim:fink.fink",
96-
displayName: "Erimayas Fink",
95+
userId: null,
96+
displayName: null,
9797
avatarUrl: null,
9898
};
9999
}

0 commit comments

Comments
 (0)