Feature summary (what you would like to be able to do and where):
CheckUser should automatically update the checkuser-temporary-account-enable-auto-reveal user option in client-side JavaScript when enabling/disabling the IP auto reveal tool
Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
Background: mw.user.options is commonly used by user scripts and gadgets to check user preferences and update behavior accordingly. The preferences are populated on page load, and are not automatically updated when running mw.Api().saveOption.
For user scripts and gadgets which would like to determine whether IP auto-reveal is enabled or not, the checkuser-temporary-account-enable-auto-reveal user option (in mw.user.options) should be updated automatically whenever the preference to enable/disable IP auto reveal is saved. This is somewhat already common practice for other extensions, see https://codesearch.wmcloud.org/search/?q=mw.user.options.set. Currently, this preference value is only valid on page load, and is not updated whenever IP auto reveal is enabled through the sidebar.
You can test the current non-ideal behavior as follows:
- Open the browser console
- Disable IP auto reveal, if enabled
- Run mw.user.options.get("checkuser-temporary-account-enable-auto-reveal") (value should be null)
- Enable IP auto reveal, do not refresh
- Run mw.user.options.get("checkuser-temporary-account-enable-auto-reveal") (value is still null, not ideal)
- Refresh
- Run mw.user.options.get("checkuser-temporary-account-enable-auto-reveal") (value should be a UNIX timestamp)
- Disable IP auto reveal
- Run mw.user.options.get("checkuser-temporary-account-enable-auto-reveal") (value is still a UNIX timestamp, not ideal)
Extra note is that a common pitfall of mw.user.options.set is that it does not perform type conversion. Since the received value when the page loads with IP auto reveal enabled is of type string, the value should probably be stringified ("1762321073" instead of 1762321073) before it's put into mw.user.options.set as well.
Benefits (why should this be implemented?):
- Removes a step requiring a full API request to get live user options to check if IP auto reveal is enabled or not
- Improves temporary account integration with user scripts and gadgets