Skip to content

feat(sticky): add setting to disable sticky pinning on All Discussions page#4608

Closed
gianniguida wants to merge 1 commit intoflarum:2.xfrom
glowingblue:gg/feat-pin-sticky-on-all-setting-2x
Closed

feat(sticky): add setting to disable sticky pinning on All Discussions page#4608
gianniguida wants to merge 1 commit intoflarum:2.xfrom
glowingblue:gg/feat-pin-sticky-on-all-setting-2x

Conversation

@gianniguida
Copy link
Copy Markdown
Contributor

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 PinStickiedDiscussionsToTop so the new toggle is the master gate for /all and only_sticky_unread_discussions becomes subordinate to it.

Motivation

The unread-only floating on /all (introduced via only_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 /all purely 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_discussions
only_unread = flarum-sticky.only_sticky_unread_discussions

Page pin_on_all=true, only_unread=true (default) pin_on_all=true, only_unread=false pin_on_all=false
/all Unread sticky pinned (UNION) All sticky pinned to top No pinning — natural last_posted_at order
Tag page All sticky pinned All sticky pinned All sticky pinned (setting irrelevant)
Other filters No pinning No pinning No pinning

When pin_on_all=false, the only_unread setting 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 — register pin_sticky_on_all_discussions (default true) and consolidate the three Extend\Settings declarations into a single block.
  • src/PinStickiedDiscussionsToTop.php — reorder the __invoke flow so tag pages are handled first, then pin_on_all gates the /all path, then only_unread decides the pinning style. The new ordering keeps tag-page behavior unchanged.
  • js/src/admin/extend.tsx — add a boolean toggle for pin_on_all directly above only_unread, and add a disabled predicate on only_unread that reflects the persisted pin_on_all value.
  • locale/en.yml — add admin.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_discussions semantics are preserved when pin_on_all is true (the default).

Tests added

  • list_discussions_does_not_pin_sticky_on_all_when_pin_setting_disabled_as_guestpin_on_all=false as 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_pagespin_on_all=false with 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_discussions reads app.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

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.
@gianniguida gianniguida requested a review from a team as a code owner April 29, 2026 13:54
@gianniguida gianniguida changed the title feat(sticky): add setting to disable sticky pinning on All Discussions feat(sticky): add setting to disable sticky pinning on All Discussions page Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant