discourse/lib/topic_view
Mark VanLandingham ff700ad8c3
DEV: Various changes to support nested posts experiment (#37785)
This PR adds several reusable pieces to Core that the
discourse-nested-replies
plugin needs, while keeping them general-purpose enough to be useful to
other
  plugins and future Core work.

  ## Summary

  ### TopicMetadata component extraction
  - Extracts the category chooser, tag chooser, plugin outlets, and
    save/cancel controls from `topic.gjs` into a standalone
    `<TopicCategoryTagEditor>` component
  - The nested-replies plugin reuses this component in its own topic
    header, avoiding duplication of ~55 lines of template code
  - No behavioral change to the existing topic page

  ### Value transformers for URL routing
  - **`route-to-url`** — applied in `DiscourseURL.routeTo()`, allows
    plugins to intercept and rewrite navigation URLs before routing
    occurs. Returns early if the transformer nullifies the path.
- **`topic-url-for-post-number`** — applied in `Topic#urlForPostNumber`,
    allows plugins to rewrite per-post URLs (e.g. for nested views)
- **`post-share-url`** 

  ### TopicView `PostDependentCache` concern
  - Introduces `memoize_for_posts` — a declarative way to register
    instance variables that should be cleared when posts are replaced
  - Provides `reset_post_collection(posts:)` — an explicit method for
    swapping the post collection on a TopicView after initialization,
    automatically clearing all registered caches
  - Adds `skip_post_loading` initializer option so plugins that supply
    their own posts can skip the default post-loading SQL entirely
  - 4 specs covering replacement, cache clearing, preload hooks, and
    skip_post_loading

---------

Co-authored-by: Isaac Janzen <isaac.janzen@discourse.org>
2026-03-09 15:47:03 -05:00
..
post_dependent_cache.rb