feat(sticky): add setting to disable sticky pinning on All Discussions page#4608
Closed
gianniguida wants to merge 1 commit intoflarum:2.xfrom
Closed
feat(sticky): add setting to disable sticky pinning on All Discussions page#4608gianniguida wants to merge 1 commit intoflarum:2.xfrom
gianniguida wants to merge 1 commit intoflarum:2.xfrom
Conversation
Adds an admin toggle (default: enabled) that gates sticky pinning on the All Discussions page. When disabled, stickied discussions appear at their natural last_posted_at position. Tag pages are unaffected. Restructures PinStickiedDiscussionsToTop so the new toggle is the master gate for /all and properly subordinates only_sticky_unread_- discussions, which is shown disabled in the admin UI when the master toggle is off. Consolidates multiple Extend\Settings declarations into one block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an admin setting
flarum-sticky.pin_sticky_on_all_discussions(default:true) that controls whether stickied discussions are pinned to the top of the All Discussions page. Tag pages are unaffected.This is the 2.x counterpart of #4607 (1.x). It also restructures
PinStickiedDiscussionsToTopso the new toggle is the master gate for/allandonly_sticky_unread_discussionsbecomes subordinate to it.Motivation
The unread-only floating on
/all(introduced viaonly_sticky_unread_discussions) helps until you have long-lived sticky announcements (rules, FAQs). For new visitors, those sticky are always unread, so they pin permanently and push fresh activity down. Some communities want the option to treat/allpurely as latest activity, while keeping sticky pinning inside individual tag pages where it remains useful.Behavior matrix
pin_on_all=flarum-sticky.pin_sticky_on_all_discussionsonly_unread=flarum-sticky.only_sticky_unread_discussionspin_on_all=true,only_unread=true(default)pin_on_all=true,only_unread=falsepin_on_all=false/alllast_posted_atorderWhen
pin_on_all=false, theonly_unreadsetting becomes a no-op — the admin UI greys it out (after save) since the read/unread distinction can't apply to discussions that aren't pinned.Changes
extend.php— registerpin_sticky_on_all_discussions(defaulttrue) and consolidate the threeExtend\Settingsdeclarations into a single block.src/PinStickiedDiscussionsToTop.php— reorder the__invokeflow so tag pages are handled first, thenpin_on_allgates the/allpath, thenonly_unreaddecides the pinning style. The new ordering keeps tag-page behavior unchanged.js/src/admin/extend.tsx— add a boolean toggle forpin_on_alldirectly aboveonly_unread, and add adisabledpredicate ononly_unreadthat reflects the persistedpin_on_allvalue.locale/en.yml— addadmin.settings.pin_sticky_on_all_discussions_{label,help}.tests/integration/api/ListDiscussionsTest.php— three new tests (see below).Backwards compatibility
The default value matches existing behavior, so this is a no-op on upgrade. No migration needed. Existing
only_sticky_unread_discussionssemantics are preserved whenpin_on_allistrue(the default).Tests added
list_discussions_does_not_pin_sticky_on_all_when_pin_setting_disabled_as_guest—pin_on_all=falseas guest, expects natural order on/all.list_discussions_pin_setting_disabled_overrides_only_unread_setting_on_all— both settings off, authenticated user with unread sticky, still expects natural order — proves master-gate precedence.list_discussions_pin_setting_disabled_does_not_affect_tag_pages—pin_on_all=falsewith a tag filter, expects all sticky pinned — proves the gate is/all-scoped.All existing tests continue to pass unchanged.
Notes
The admin disabled-state on
only_sticky_unread_discussionsreadsapp.data.settings, which reflects persisted values. So the disabled state updates after save. A fully reactive (no-save-needed) version would require a custom component subscribing to the in-progress form stream — left out as a polish item.Related