Commit Graph

7 Commits

Author SHA1 Message Date
Aman Agrawal 34a37f55d6 spectators: Rename is_web_public_compatible functions. 2021-09-06 09:00:16 -07:00
Aman Agrawal cfd81b1bf4 login_to_access: Take user to web_public_compatible hash on exit.
We save the last web_public_compatible hash that user visited
before the modal was shown and take user to that hash when
user exits the modal.
2021-09-06 09:00:16 -07:00
Aman Agrawal 40acc9b27c browser_history: If changing_hash, don't set to hash_before_overlay.
If we are changing_hash, it means `window.location.hash` is the
new_hash, so we don't want to change hash further now.

This used to create a loop of changing hashes as we used to close
and open overlays if `hash_before_overlay` was an overlay.

Fixes #18011
2021-04-09 08:24:02 -07:00
Aman Agrawal fd2e0e7a1f hashchange: Store `changing_hash` in browser_history state.
This will allow us to more widely access this variable and use it
outside of hashchange as well.
2021-04-09 08:24:02 -07:00
Aman Agrawal eb72f77d0a settings: Allow switching between user and org settings manually.
Since the base hash for org settings and user settings are
different (organization and settings), the hashchange module
gets confused that we are going from one overlay to other.

A reproducer for this flow is to visit the organization "Bots" page,
click on your own profile as the owner of a bot, and then click "Edit
profile" from there.

So, we fix this by making an exception for this particular case
in the module.

Fixes part of #18011.
2021-04-07 01:02:03 -07:00
Anders Kaseorg 6de39ae92d js: Clean up typeof … === "undefined" checks.
The only reason to use typeof foo === "undefined" is when foo is a
global identifier that might not have been declared at all, so it
might raise a ReferenceError if evaluated.  For a variable declared
with const or let or import, a function argument, or a complex
expression, simply foo === undefined is equivalent.

Some of these conditions have become impossible and can be removed
entirely, and some can be replaced more idiomatically with default
parameters (note that JavaScript does not share the Python misfeature
of evaluating the default parameter at function declaration time).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-24 13:15:01 -07:00
Steve Howell 746cc9e1f6 refactor: Extract browser_history module.
This mainly extracts a new module called
browser_history. It has much fewer dependencies
than hashchange.js, so any modules that just
need the smaller API from browser_history now
have fewer transitive dependencies.

Here are some details:
    * Move is_overlay_hash to hash_util.
    * Rename hashchange.update_browser_history to
      brower_history.update
    * Move go_to_location verbatim.
    * Remove unused argument for exit_overlay.
    * Introduce helper functions:
        * old_hash()
        * set_hash_before_overlay()
        * save_old_hash()

We now have 100% line coverage on the extracted
code.
2021-03-22 13:29:32 -07:00