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

Show a loading state for slow peeks #3142

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions res/css/views/rooms/_RoomPreviewBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ limitations under the License.
margin: 10px 10px 10px 0;
flex: 0 0 auto;
}

.mx_RoomPreviewBar_footer {
font-size: 12px;
line-height: 20px;

.mx_Spinner {
vertical-align: middle;
display: inline-block;
}
}
}

.mx_RoomPreviewBar_dark {
Expand Down
1 change: 1 addition & 0 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ module.exports = React.createClass({
<div className="mx_RoomView">
<RoomPreviewBar
canPreview={false}
previewLoading={this.state.peekLoading}
error={this.state.roomLoadError}
loading={loading}
joining={this.state.joining}
Expand Down
16 changes: 15 additions & 1 deletion src/components/views/rooms/RoomPreviewBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = React.createClass({
error: PropTypes.object,

canPreview: PropTypes.bool,
previewLoading: PropTypes.bool,
room: PropTypes.object,

// When a spinner is present, a spinnerState can be specified to indicate the
Expand Down Expand Up @@ -254,6 +255,8 @@ module.exports = React.createClass({
},

render: function() {
const Spinner = sdk.getComponent('elements.Spinner');

let showSpinner = false;
let darkStyle = false;
let title;
Expand All @@ -262,6 +265,7 @@ module.exports = React.createClass({
let primaryActionLabel;
let secondaryActionHandler;
let secondaryActionLabel;
let footer;

const messageCase = this._getMessageCase();
switch (messageCase) {
Expand All @@ -287,6 +291,14 @@ module.exports = React.createClass({
primaryActionHandler = this.onRegisterClick;
secondaryActionLabel = _t("Sign In");
secondaryActionHandler = this.onLoginClick;
if (this.props.previewLoading) {
footer = (
<div>
<Spinner w={20} h={20}/>
{_t("Loading room preview")}
</div>
);
}
break;
}
case MessageCase.Kicked: {
Expand Down Expand Up @@ -433,7 +445,6 @@ module.exports = React.createClass({
}

const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
const Spinner = sdk.getComponent('elements.Spinner');

let subTitleElements;
if (subTitle) {
Expand Down Expand Up @@ -484,6 +495,9 @@ module.exports = React.createClass({
{ secondaryButton }
{ primaryButton }
</div>
<div className="mx_RoomPreviewBar_footer">
{ footer }
</div>
</div>
);
},
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@
"Join the conversation with an account": "Join the conversation with an account",
"Sign Up": "Sign Up",
"Sign In": "Sign In",
"Loading room preview": "Loading room preview",
"You were kicked from %(roomName)s by %(memberName)s": "You were kicked from %(roomName)s by %(memberName)s",
"Reason: %(reason)s": "Reason: %(reason)s",
"Forget this room": "Forget this room",
Expand Down