neuer chat, weniger raten?
This commit is contained in:
parent
a4546a46df
commit
f9e8f62e9c
|
|
@ -5,55 +5,60 @@ import Switch from 'flarum/common/components/Switch';
|
||||||
import Component from 'flarum/common/Component';
|
import Component from 'flarum/common/Component';
|
||||||
|
|
||||||
class TeamsSettingsBlock extends Component {
|
class TeamsSettingsBlock extends Component {
|
||||||
|
oninit(vnode) {
|
||||||
|
super.oninit(vnode);
|
||||||
|
|
||||||
|
// Serialisiert Saves, damit schnelle Klicks nicht zu "last write wins" führen.
|
||||||
|
this.saveChain = Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
queueSave(user, preferences) {
|
||||||
|
this.saveChain = this.saveChain.then(() => user.savePreferences(preferences));
|
||||||
|
return this.saveChain;
|
||||||
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
const user = app.session.user;
|
const user = app.session.user;
|
||||||
const prefs = user.preferences() || {};
|
|
||||||
|
// Sicherheitscheck: SettingsPage ist nur für eingeloggte Nutzer, aber defensiv bleibt defensiv.
|
||||||
|
if (!user) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="TeamsSettings Block">
|
<div className="TeamsSettings Block">
|
||||||
<h3>Microsoft Teams</h3>
|
<h3>Microsoft Teams</h3>
|
||||||
|
|
||||||
{this.prefSwitch(
|
{this.prefSwitch(user, 'sbp-jm-msteams.enabled', 'Enable Microsoft Teams notifications')}
|
||||||
user,
|
|
||||||
prefs,
|
|
||||||
'sbp-jm-msteams.enabled',
|
|
||||||
'Enable Microsoft Teams notifications'
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="TeamsSettings-options">
|
<div className="TeamsSettings-options">
|
||||||
{this.prefSwitch(
|
{this.prefSwitch(
|
||||||
user,
|
user,
|
||||||
prefs,
|
|
||||||
'sbp-jm-msteams.types.newPost',
|
'sbp-jm-msteams.types.newPost',
|
||||||
'Someone replies to a discussion I am following'
|
'Someone replies to a discussion I am following'
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{this.prefSwitch(
|
{this.prefSwitch(user, 'sbp-jm-msteams.types.postMentioned', 'Someone mentions me in a post')}
|
||||||
user,
|
|
||||||
prefs,
|
|
||||||
'sbp-jm-msteams.types.postMentioned',
|
|
||||||
'Someone mentions me in a post'
|
|
||||||
)}
|
|
||||||
|
|
||||||
{this.prefSwitch(
|
{this.prefSwitch(user, 'sbp-jm-msteams.types.userMentioned', 'Someone mentions me')}
|
||||||
user,
|
|
||||||
prefs,
|
|
||||||
'sbp-jm-msteams.types.userMentioned',
|
|
||||||
'Someone mentions me'
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
prefSwitch(user, prefs, key, label) {
|
prefSwitch(user, key, label) {
|
||||||
|
const prefs = user.preferences() || {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch
|
<Switch
|
||||||
state={!!prefs[key]}
|
state={!!prefs[key]}
|
||||||
onchange={(value) => {
|
onchange={(value) => {
|
||||||
user.savePreferences({
|
// Wichtig: Merge statt Partial-Objekt, damit andere Toggles nicht "verschwinden"
|
||||||
|
// (Front-end Model hält preferences als ein Attribut).
|
||||||
|
const merged = {
|
||||||
|
...(user.preferences() || {}),
|
||||||
[key]: value,
|
[key]: value,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return this.queueSave(user, merged);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue