Suppress updating of URL during topic navigation


(Sam Saffron) #1

This plugin demonstrates how to add a custom setting to users, that is later passed back to current user (meaning you will have access to it on every page load)

  1. It adds a user preference to disable “replaceState” during topic navigation.
  2. It ensures the setting is shipped to clients with Discourse.User.current().

Important API notes:

To register custom_fields to be serialized with current user use:

DiscoursePluginRegistry.serialized_current_user_fields << "my_field"

To specify a type for a custom field use:

after_initialize do
  User.register_custom_field_type('my_field', :boolean)

It can be used to keep browser history less cluttered.

Options to disable hijack of CMD+F / CTRL+F and "/" keys for search?
Change button depending on UserCustomField?
Slow scrolling in Chrome due to replaceState bug