Skip to content

[2.x] feat: add setting to disable sticky pinning on All Discussions page - #4609

Merged
imorland merged 3 commits into
flarum:2.xfrom
glowingblue:gg/feat-pin-sticky-on-all-setting-2x
Jul 29, 2026
Merged

[2.x] feat: add setting to disable sticky pinning on All Discussions page#4609
imorland merged 3 commits into
flarum: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 14:04
@imorland imorland added this to the 2.1 milestone May 12, 2026
@imorland imorland modified the milestones: 2.1, 2.0.0-rc.6 Jul 29, 2026
imorland added 2 commits July 29, 2026 18:08
Resolve extend.php: keep the consolidated Settings block from this branch and
the Extend\Conditional (realtime + audit) block that landed on 2.x.

# Conflicts:
#	extensions/sticky/extend.php
With only_sticky_unread_discussions off, the reordered mutator no longer
pins stickied discussions on filtered listings other than a single tag page
(e.g. a by-author search) — pinning is scoped to /all and single-tag pages.
This locks that behaviour, which previously went untested.
@imorland
imorland merged commit 2b4932c into flarum:2.x Jul 29, 2026
19 checks passed
@imorland
imorland deleted the gg/feat-pin-sticky-on-all-setting-2x branch July 29, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants