Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get and display a user's pushers in settings #1374

Merged
merged 3 commits into from
Apr 12, 2016
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
42 changes: 41 additions & 1 deletion src/components/views/settings/Notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ module.exports = React.createClass({

_refreshFromServer: function() {
var self = this;
MatrixClientPeg.get().getPushRules().then(self._portRulesToNewAPI).done(function(rulesets) {
var pushRulesPromise = MatrixClientPeg.get().getPushRules().then(self._portRulesToNewAPI).done(function(rulesets) {
MatrixClientPeg.get().pushRules = rulesets;

// Get homeserver default rules and triage them by categories
Expand Down Expand Up @@ -811,10 +811,20 @@ module.exports = React.createClass({
self.state.externalPushRules.push(rule);
}
}
});

var pushersPromise = MatrixClientPeg.get().getPushers().then(function(resp) {
self.setState({pushers: resp.pushers});
});

q.all([pushRulesPromise, pushersPromise]).done(function() {
self.setState({
phase: self.phases.DISPLAY
});
}, function(error) {
self.setState({
phase: self.phases.ERROR
});
});
},

Expand Down Expand Up @@ -936,6 +946,32 @@ module.exports = React.createClass({
externalRules.push(<li>Notifications on the following keywords follow rules which can’t be displayed here: { externalKeyWords }</li>);
}

var devicesSection;
if (this.state.pushers === undefined) {
devicesSection = <div className="error">Unable to fetch device list</div>
} else if (this.state.pushers.length == 0) {
devicesSection = <div className="mx_UserSettings_devicesTable_nodevices">
No devices are receiving push notifications
</div>
} else {
// It would be great to be able to delete pushers from here too,
// and this wouldn't be hard to add.
var rows = [];
for (var i = 0; i < this.state.pushers.length; ++i) {
rows.push(<tr>
<td>{this.state.pushers[i].app_display_name}</td>
<td>{this.state.pushers[i].device_display_name}</td>
</tr>);
}
devicesSection = (<table className="mx_UserSettings_devicesTable">
<tr>
<th>Application</th>
<th>Device</th>
</tr>
{rows}
</table>);
}

var advancedSettings;
if (externalRules.length) {
advancedSettings = (
Expand Down Expand Up @@ -1010,6 +1046,10 @@ module.exports = React.createClass({
</table>
</div>

<h3>Devices</h3>

{ devicesSection }

{ advancedSettings }

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ limitations under the License.
cursor: pointer;
color: #76cfa6;
}

.mx_UserSettings_devicesTable td {
padding-left: 20px;
padding-right: 20px;
}
.mx_UserSettings_devicesTable_nodevices {
font-style: italic;
}