Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DEV: Add page-aware plugin APIs for saving user preferences#36757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ZogStriP merged 2 commits intomainfromdev-add-page-specific-saving-to-plugin-api
Dec 18, 2025

Conversation

@ZogStriP
Copy link
Member

@ZogStriPZogStriP commentedDec 17, 2025
edited
Loading

Previously, plugins that needed to save user preferences on specific preference pages had to either:

  1. Manually register value transformers forpreferences-save-attributes
  2. UsemodifyClass to push fields tosaveAttrNames

The second approach was broken becausesaveAttrNames is now a getter that returns a fresh array each time, so pushed values were lost.

This commit introduces three new plugin APIs that handle the transformer registration automatically:

  • addSaveableUserOption(name, { page }) - foruser_options table fields
  • addSaveableUserField(name, { page }) - foruser_fields table fields
  • addSaveableCustomFields(page) - ensurescustom_fields object is saved on a page (auto-deduplicates across plugins)

The{ page } option specifies which preferences page triggers saving: "account", "emails", "interface", "notifications", "profile", "tracking", etc.

Also updates bundled plugins to use the new APIs:

  • chat:addSaveableUserOption with{ page: "emails" } for email frequency
  • discourse-ai:addSaveableUserOption with{ page: "interface" }
  • discourse-assign:addSaveableUserOption with{ page: "tracking" },addSaveableCustomFields with"notifications"
  • discourse-policy:addSaveableUserOption with{ page: "emails" }
  • discourse-rewind:addSaveableUserOption (no page, custom prefs page)

DeprecatesaddSaveableUserOptionField in favor ofaddSaveableUserOption.

Ref -https://meta.discourse.org/t/391509

Follow up toee1a1c7

moin-Jana and megothss reacted with heart emoji
Previously, plugins that needed to save user preferences on specificpreference pages had to either:1. Manually register value transformers for `preferences-save-attributes`2. Use `modifyClass` to push fields to `saveAttrNames`The second approach was broken because `saveAttrNames` is now a getterthat returns a fresh array each time, so pushed values were lost.This commit introduces three new plugin APIs that handle the transformerregistration automatically:- `addSaveableUserOption(name, { page })` - for user_options table fields- `addSaveableUserField(name, { page })` - for user_fields table fields- `addSaveableCustomFields({ page })` - ensures custom_fields object is  saved on a page (auto-deduplicates across plugins)The `{ page }` option specifies which preferences page triggers saving:"account", "emails", "interface", "notifications", "profile", "tracking", etc.Also updates bundled plugins to use the new APIs:- chat: `addSaveableUserOption` with `{ page: "emails" }` for email frequency- discourse-ai: `addSaveableUserOption` with `{ page: "interface" }`- discourse-assign: `addSaveableUserOption` with `{ page: "tracking" }`,  `addSaveableCustomFields` with `{ page: "notifications" }`- discourse-policy: `addSaveableUserOption` with `{ page: "emails" }`- discourse-rewind: `addSaveableUserOption` (no page, custom prefs page)Deprecates `addSaveableUserOptionField` in favor of `addSaveableUserOption`.Ref -https://meta.discourse.org/t/391509Follow up toee1a1c7
@github-actionsgithub-actionsbot added chatPRs which include a change to Chat plugin discourse-assign discourse-ai discourse-policy labelsDec 17, 2025
ZogStriP added a commit to discourse/discourse-follow that referenced this pull requestDec 17, 2025
Replace manual `modifyClass` controller override with the new`addSaveableCustomFields({ page: "notifications" })` API.The previous approach of pushing to `saveAttrNames` in a `save()` overridewas broken because `saveAttrNames` is now a getter returning a fresh array.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-code-review that referenced this pull requestDec 17, 2025
Replace manual `modifyClass` controller override with the new`addSaveableCustomFields({ page: "notifications" })` API.The previous approach of pushing to `saveAttrNames` in `init()` was brokenbecause `saveAttrNames` is now a getter returning a fresh array.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-newsletter-integration that referenced this pull requestDec 17, 2025
Simplify preference saving by using the new`addSaveableUserField(name, { page: "emails" })` API.This replaces manual value transformer registration and backwardcompatibility code with a single declarative API call.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-solved-reminders-plugin that referenced this pull requestDec 17, 2025
Replace manual `modifyClass` controller override with the new`addSaveableCustomFields({ page: "notifications" })` API.The previous approach of pushing to `saveAttrNames` in a `save()` overridewas broken because `saveAttrNames` is now a getter returning a fresh array.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-signatures that referenced this pull requestDec 17, 2025
This updates the signature preferences connector to use modernEmber patterns and the new plugin API.Changes:- Convert to Glimmer component with @outletArgs pattern- Use@service injection for siteSettings- Replace classic <Input> with native <input> and {{on}} modifier- Use new api.addSaveableCustomFields({ page: "profile" }) API  instead of modifyClass save() override- Remove dead @showUploadModal argument from DEditor- Add CSS to hide preview panel and match bio editor widthThe modifyClass pattern for saving custom_fields was problematicbecause saveAttrNames is now a getter that returns a fresh arrayeach call, so pushing to it in save() had no effect. The newaddSaveableCustomFields API uses value transformers to properlyadd "custom_fields" to the save attributes.cf.discourse/discourse#36757
Copy link
Contributor

@pmusarajpmusaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks good to me. I wonder if someone from dev-xp can also review, though, to ensure consistency across APIs.

Changed from `addSaveableCustomFields({ page })` to`addSaveableCustomFields(page)` since `page` is the only requiredparameter. The options object pattern implied it was optional whenit's actually mandatory.Also improved error handling to throw in development/tests when`page` is missing, rather than just logging a warning.
@ZogStriPZogStriP merged commitb66fca7 intomainDec 18, 2025
18 checks passed
@ZogStriPZogStriP deleted the dev-add-page-specific-saving-to-plugin-api branchDecember 18, 2025 09:58
ZogStriP added a commit to discourse/discourse-follow that referenced this pull requestDec 18, 2025
Follow-up to discourse/discourse commit that simplified the methodsignature from `addSaveableCustomFields({ page })` to`addSaveableCustomFields(page)`.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-code-review that referenced this pull requestDec 18, 2025
Follow-up to discourse/discourse commit that simplified the methodsignature from `addSaveableCustomFields({ page })` to`addSaveableCustomFields(page)`.cf.discourse/discourse#36757
ZogStriP added a commit to discourse/discourse-solved-reminders-plugin that referenced this pull requestDec 18, 2025
Follow-up to discourse/discourse commit that simplified the methodsignature from `addSaveableCustomFields({ page })` to`addSaveableCustomFields(page)`.cf.discourse/discourse#36757
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@megothssmegothssmegothss left review comments

@pmusarajpmusarajpmusaraj approved these changes

Assignees

No one assigned

Labels

chatPRs which include a change to Chat plugindiscourse-aidiscourse-assigndiscourse-policy

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ZogStriP@pmusaraj@megothss

[8]ページ先頭

©2009-2025 Movatter.jp