weitergeraten
This commit is contained in:
parent
addfb772a2
commit
b7155b36ca
|
|
@ -7,36 +7,36 @@ import Component from 'flarum/common/Component';
|
|||
class TeamsSettingsBlock extends Component {
|
||||
view() {
|
||||
const user = app.session.user;
|
||||
const prefs = user.preferences() || {};
|
||||
|
||||
return (
|
||||
<div className="TeamsSettings Block">
|
||||
<h3>Microsoft Teams</h3>
|
||||
|
||||
<Switch
|
||||
state={user.preference('sbp-jm-msteams.enabled')}
|
||||
onchange={(value) =>
|
||||
user.savePreferences({
|
||||
'sbp-jm-msteams.enabled': value,
|
||||
})
|
||||
}
|
||||
>
|
||||
Enable Microsoft Teams notifications
|
||||
</Switch>
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
prefs,
|
||||
'sbp-jm-msteams.enabled',
|
||||
'Enable Microsoft Teams notifications'
|
||||
)}
|
||||
|
||||
<div className="TeamsSettings-options">
|
||||
{this.typeSwitch(
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
'newPost',
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.newPost',
|
||||
'Someone replies to a discussion I am following'
|
||||
)}
|
||||
{this.typeSwitch(
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
'postMentioned',
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.postMentioned',
|
||||
'Someone mentions me in a post'
|
||||
)}
|
||||
{this.typeSwitch(
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
'userMentioned',
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.userMentioned',
|
||||
'Someone mentions me'
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -44,17 +44,11 @@ class TeamsSettingsBlock extends Component {
|
|||
);
|
||||
}
|
||||
|
||||
typeSwitch(user, type, label) {
|
||||
const key = `sbp-jm-msteams.types.${type}`;
|
||||
|
||||
prefSwitch(user, prefs, key, label) {
|
||||
return (
|
||||
<Switch
|
||||
state={user.preference(key)}
|
||||
onchange={(value) =>
|
||||
user.savePreferences({
|
||||
[key]: value,
|
||||
})
|
||||
}
|
||||
state={!!prefs[key]}
|
||||
onchange={(value) => user.savePreferences({ [key]: value })}
|
||||
>
|
||||
{label}
|
||||
</Switch>
|
||||
|
|
@ -64,7 +58,6 @@ class TeamsSettingsBlock extends Component {
|
|||
|
||||
export default function addTeamsSettings() {
|
||||
extend(SettingsPage.prototype, 'content', function (vnode) {
|
||||
// ✅ content ist ein Array → push!
|
||||
vnode.children.push(<TeamsSettingsBlock />);
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue