weitergeraten

This commit is contained in:
JM 2026-05-06 11:35:15 +02:00
parent addfb772a2
commit b7155b36ca
1 changed files with 19 additions and 26 deletions

View File

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