Skip to content

Commit 9dfd0bc

Browse files
committed
Show a spinner if creating a room on "Start chat" click
Use a gif instead of 'orrible CSS spinners which are CPU hungry. Encapsulate it in a very basic Spinner atom.
1 parent ed52bc3 commit 9dfd0bc

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

src/skins/vector/css/common.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ a:visited {
8686
cursor: pointer;
8787
}
8888

89+
.mx_ContextualMenu_spinner {
90+
display: block;
91+
margin: 0 auto;
92+
}
8993

9094
.mx_Dialog_background {
9195
position: fixed;

src/skins/vector/img/spinner.gif

33.6 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
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+
'use strict';
18+
19+
var React = require('react');
20+
21+
module.exports = React.createClass({
22+
displayName: 'Spinner',
23+
24+
render: function() {
25+
var w = this.props.w || 32;
26+
var h = this.props.h || 32;
27+
var imgClass = this.props.imgClassName || "";
28+
return (
29+
<div>
30+
<img src="img/spinner.gif" width={w} height={h} className={imgClass}/>
31+
</div>
32+
);
33+
}
34+
});

src/skins/vector/views/molecules/MemberInfo.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
'use strict';
1818

1919
var React = require('react');
20+
var Loader = require("../atoms/Spinner");
2021

2122
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
2223
var MemberInfoController = require('matrix-react-sdk/lib/controllers/molecules/MemberInfo')
@@ -26,14 +27,18 @@ module.exports = React.createClass({
2627
mixins: [MemberInfoController],
2728

2829
render: function() {
29-
var interactButton, kickButton, banButton, muteButton, giveModButton;
30+
var interactButton, kickButton, banButton, muteButton, giveModButton, spinner;
3031
if (this.props.member.userId === MatrixClientPeg.get().credentials.userId) {
3132
interactButton = <div className="mx_ContextualMenu_field" onClick={this.onLeaveClick}>Leave room</div>;
3233
}
3334
else {
3435
interactButton = <div className="mx_ContextualMenu_field" onClick={this.onChatClick}>Start chat</div>;
3536
}
3637

38+
if (this.state.creatingRoom) {
39+
spinner = <Loader imgClassName="mx_ContextualMenu_spinner"/>;
40+
}
41+
3742
if (this.state.can.kick) {
3843
kickButton = <div className="mx_ContextualMenu_field" onClick={this.onKick}>
3944
Kick
@@ -64,6 +69,7 @@ module.exports = React.createClass({
6469
{kickButton}
6570
{banButton}
6671
{giveModButton}
72+
{spinner}
6773
</div>
6874
);
6975
}

0 commit comments

Comments
 (0)