Embed existing notifications settings into the tab
parent
73bce4d645
commit
d267f232bc
|
@ -23,6 +23,7 @@ import GeneralSettingsTab from "../settings/tabs/GeneralSettingsTab";
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import LabsSettingsTab from "../settings/tabs/LabsSettingsTab";
|
import LabsSettingsTab from "../settings/tabs/LabsSettingsTab";
|
||||||
|
import NotificationSettingsTab from "../settings/tabs/NotificationSettingsTab";
|
||||||
|
|
||||||
// TODO: Ditch this whole component
|
// TODO: Ditch this whole component
|
||||||
export class TempTab extends React.Component {
|
export class TempTab extends React.Component {
|
||||||
|
@ -56,7 +57,7 @@ export default class UserSettingsDialog extends React.Component {
|
||||||
tabs.push(new Tab(
|
tabs.push(new Tab(
|
||||||
_td("Notifications"),
|
_td("Notifications"),
|
||||||
"mx_UserSettingsDialog_bellIcon",
|
"mx_UserSettingsDialog_bellIcon",
|
||||||
<div>Notifications Test</div>,
|
<NotificationSettingsTab />,
|
||||||
));
|
));
|
||||||
tabs.push(new Tab(
|
tabs.push(new Tab(
|
||||||
_td("Preferences"),
|
_td("Preferences"),
|
||||||
|
|
|
@ -28,6 +28,7 @@ import {
|
||||||
PushRuleVectorState,
|
PushRuleVectorState,
|
||||||
ContentRules,
|
ContentRules,
|
||||||
} from '../../../notifications';
|
} from '../../../notifications';
|
||||||
|
import * as SdkConfig from "../../../SdkConfig";
|
||||||
|
|
||||||
// TODO: this "view" component still has far too much application logic in it,
|
// TODO: this "view" component still has far too much application logic in it,
|
||||||
// which should be factored out to other files.
|
// which should be factored out to other files.
|
||||||
|
@ -73,8 +74,6 @@ module.exports = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
// The array of threepids from the JS SDK (required for email notifications)
|
// The array of threepids from the JS SDK (required for email notifications)
|
||||||
threepids: React.PropTypes.array.isRequired,
|
threepids: React.PropTypes.array.isRequired,
|
||||||
// The brand string set when creating an email pusher
|
|
||||||
brand: React.PropTypes.string,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -146,7 +145,7 @@ module.exports = React.createClass({
|
||||||
let emailPusherPromise;
|
let emailPusherPromise;
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
const data = {};
|
const data = {};
|
||||||
data['brand'] = this.props.brand || 'Riot';
|
data['brand'] = SdkConfig.get().brand || 'Riot';
|
||||||
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
||||||
} else {
|
} else {
|
||||||
const emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
const emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 New Vector Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import {_t} from "../../../../languageHandler";
|
||||||
|
import MatrixClientPeg from "../../../../MatrixClientPeg";
|
||||||
|
const sdk = require("../../../../index");
|
||||||
|
|
||||||
|
export default class NotificationSettingsTab extends React.Component {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
threepids: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async componentWillMount(): void {
|
||||||
|
MatrixClientPeg.get().getThreePids().then(r => this.setState({threepids: r.threepids}));
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const Notifications = sdk.getComponent("views.settings.Notifications");
|
||||||
|
return (
|
||||||
|
<div className="mx_SettingsTab">
|
||||||
|
<div className="mx_SettingsTab_heading">{_t("Notifications")}</div>
|
||||||
|
<div className="mx_SettingsTab_section">
|
||||||
|
<Notifications threepids={this.state.threepids} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue