1# vim:fileencoding=utf-8
2# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
3from __python__ import bound_methods, hash_literals
4
5from modals import close_all_modals
6from utils import parse_url_params
7
8
9def get_current_query(newval):
10    if newval:
11        get_current_query.ans = newval
12    return get_current_query.ans or {}
13
14
15def apply_url():
16    close_all_modals()  # needed to close any error dialogs, etc when clicking back or forward in the browser or using push_state() to go to a new page
17    data = parse_url_params()
18    data.mode = data.mode or 'read_book'
19    get_current_query.ans = data
20