Skip to content

DEV: General code cleanup#29

Merged
markvanlan merged 1 commit intomainfrom
cleanup1
Mar 20, 2026
Merged

DEV: General code cleanup#29
markvanlan merged 1 commit intomainfrom
cleanup1

Conversation

@markvanlan
Copy link
Contributor

  1. api-initializers/nested-view-redirect.js — 3 fixes:
  • composerSavedFromNested → composerSaveInfo: Replaced the bare boolean with an object that tracks the topicId and time. The suppression now only fires for the same topic and expires after 5 seconds, preventing stale flags from
    silently eating unrelated navigations.
  • checkedTopicIds Set → Map with TTL: Replaced the unbounded Set with a Map storing timestamps. Entries expire after 60 seconds (so category changes are picked up) and the map is evicted when it exceeds 100 entries.
  • transition.retry race guard: Added a fromRoute check before transition.retry() and in the catch handler. If the user navigated away during the async category lookup, the stale transition is silently dropped instead of yanking
    them back.
  1. lib/nested-post-url.js — 1 fix:
  • Added getURL() wrapper: Share URLs now go through Discourse's getURL() so they include the base path on subfolder deployments.
  1. controllers/nested.js — 3 fixes:
  • MessageBus unsubscribe: Stored the specific channel path in _messageBusChannel and unsubscribe from that exact channel instead of the /topic/* wildcard, which could interfere with other listeners.
  • _handlePostChanged — set topic reference: Added post.topic = this.topic after store update so the topic reference is maintained on the record.
  • _handlePostChanged — handle deletes locally: Split out "deleted" events into _markPostDeletedLocally() which sets deleted, deleted_post_placeholder, and clears cooked on the post in the registry. This avoids the problem where
    /posts/:id.json returns 404 for non-staff on deleted posts (causing the silent catch to swallow the event with no UI update).
  1. lib/discourse_nested_replies/post_preloader.rb — 1 fix:
  • PostsArray safety methods: Added where, limit, order, not, and reorder stubs to the PostsArray shim so other plugins' on_preload hooks that call these ActiveRecord methods get safe no-ops instead of NoMethodError crashes.

@markvanlan markvanlan merged commit 22e27ca into main Mar 20, 2026
6 checks passed
@markvanlan markvanlan deleted the cleanup1 branch March 20, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants