weiterraten

This commit is contained in:
JM 2026-05-06 13:19:17 +02:00
parent 9bda6c6f92
commit ae0587e94f
1 changed files with 29 additions and 11 deletions

View File

@ -8,7 +8,7 @@ class TeamsSettingsBlock extends Component {
oninit(vnode) { oninit(vnode) {
super.oninit(vnode); super.oninit(vnode);
// Serialisiert Saves, damit schnelle Klicks nicht zu "last write wins" führen. // Serielle Saves verhindern "Überholen" bei schnellen Klicks.
this.saveChain = Promise.resolve(); this.saveChain = Promise.resolve();
} }
@ -19,15 +19,17 @@ class TeamsSettingsBlock extends Component {
view() { view() {
const user = app.session.user; const user = app.session.user;
// Sicherheitscheck: SettingsPage ist nur für eingeloggte Nutzer, aber defensiv bleibt defensiv.
if (!user) return null; if (!user) return null;
return ( return (
<div className="TeamsSettings Block"> <div className="TeamsSettings Block">
<h3>Microsoft Teams</h3> <h3>Microsoft Teams</h3>
{this.prefSwitch(user, 'sbp-jm-msteams.enabled', 'Enable Microsoft Teams notifications')} {this.prefSwitch(
user,
'sbp-jm-msteams.enabled',
'Enable Microsoft Teams notifications'
)}
<div className="TeamsSettings-options"> <div className="TeamsSettings-options">
{this.prefSwitch( {this.prefSwitch(
@ -36,9 +38,17 @@ class TeamsSettingsBlock extends Component {
'Someone replies to a discussion I am following' 'Someone replies to a discussion I am following'
)} )}
{this.prefSwitch(user, '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, 'sbp-jm-msteams.types.userMentioned', 'Someone mentions me')} {this.prefSwitch(
user,
'sbp-jm-msteams.types.userMentioned',
'Someone mentions me'
)}
</div> </div>
</div> </div>
); );
@ -51,14 +61,22 @@ class TeamsSettingsBlock extends Component {
<Switch <Switch
state={!!prefs[key]} state={!!prefs[key]}
onchange={(value) => { onchange={(value) => {
// Wichtig: Merge statt Partial-Objekt, damit andere Toggles nicht "verschwinden" const before = user.preferences() || {};
// (Front-end Model hält preferences als ein Attribut).
// ✅ KORREKT: Key dynamisch setzen
const merged = { const merged = {
...(user.preferences() || {}), ...before,
[key]: value, [key]: value,
}; };
return this.queueSave(user, merged); // Debug-Ausgaben (hilft beim Verifizieren)
console.log('[msteams prefs] key', key, 'value', value);
console.log('[msteams prefs] before', before);
console.log('[msteams prefs] merged', merged);
return this.queueSave(user, merged).then(() => {
console.log('[msteams prefs] after', user.preferences() || {});
});
}} }}
> >
{label} {label}
@ -71,4 +89,4 @@ export default function addTeamsSettings() {
extend(SettingsPage.prototype, 'content', function (vnode) { extend(SettingsPage.prototype, 'content', function (vnode) {
vnode.children.push(<TeamsSettingsBlock />); vnode.children.push(<TeamsSettingsBlock />);
}); });
} }