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';
|
||||
|
||||
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() {
|
||||
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 (
|
||||
<div className="TeamsSettings Block">
|
||||
<h3>Microsoft Teams</h3>
|
||||
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
prefs,
|
||||
'sbp-jm-msteams.enabled',
|
||||
'Enable Microsoft Teams notifications'
|
||||
)}
|
||||
{this.prefSwitch(user, 'sbp-jm-msteams.enabled', 'Enable Microsoft Teams notifications')}
|
||||
|
||||
<div className="TeamsSettings-options">
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.newPost',
|
||||
'Someone replies to a discussion I am following'
|
||||
)}
|
||||
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.postMentioned',
|
||||
'Someone mentions me in a post'
|
||||
)}
|
||||
{this.prefSwitch(user, 'sbp-jm-msteams.types.postMentioned', 'Someone mentions me in a post')}
|
||||
|
||||
{this.prefSwitch(
|
||||
user,
|
||||
prefs,
|
||||
'sbp-jm-msteams.types.userMentioned',
|
||||
'Someone mentions me'
|
||||
)}
|
||||
{this.prefSwitch(user, 'sbp-jm-msteams.types.userMentioned', 'Someone mentions me')}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
prefSwitch(user, prefs, key, label) {
|
||||
prefSwitch(user, key, label) {
|
||||
const prefs = user.preferences() || {};
|
||||
|
||||
return (
|
||||
<Switch
|
||||
state={!!prefs[key]}
|
||||
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,
|
||||
});
|
||||
};
|
||||
|
||||
return this.queueSave(user, merged);
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
|
|
|
|||
Loading…
Reference in New Issue