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.
This commit is contained in:
Steve Howell
2021-03-22 15:09:12 +00:00
committed by Tim Abbott
parent 67a487db79
commit 746cc9e1f6
23 changed files with 194 additions and 126 deletions

View File

@@ -5,12 +5,12 @@ import $ from "jquery";
import render_draft_table_body from "../templates/draft_table_body.hbs";
import * as blueslip from "./blueslip";
import * as browser_history from "./browser_history";
import * as compose from "./compose";
import * as compose_actions from "./compose_actions";
import * as compose_fade from "./compose_fade";
import * as compose_state from "./compose_state";
import * as compose_ui from "./compose_ui";
import * as hashchange from "./hashchange";
import {localstorage} from "./localstorage";
import * as markdown from "./markdown";
import * as narrow from "./narrow";
@@ -527,7 +527,7 @@ export function open_overlay() {
name: "drafts",
overlay: $("#draft_overlay"),
on_close() {
hashchange.exit_overlay();
browser_history.exit_overlay();
},
});
}