Applied history state pushing.
Co-authored-by: nostr-pleb21
This commit is contained in:
parent
190c1d7e40
commit
e4d6788bfa
1 changed files with 14 additions and 1 deletions
|
@ -9,7 +9,16 @@ function view_get_timeline_el() {
|
|||
return find_node("#timeline");
|
||||
}
|
||||
|
||||
function view_timeline_apply_mode(model, mode, opts={}) {
|
||||
// TODO clean up popstate listener (move to init method or such)
|
||||
window.addEventListener("popstate", function(event) {
|
||||
if (event.state && event.state.mode) {
|
||||
// Update the timeline mode.
|
||||
// Pass pushState=false to avoid adding another state to the history
|
||||
view_timeline_apply_mode(DAMUS, event.state.mode, event.state.opts, false);
|
||||
}
|
||||
})
|
||||
|
||||
function view_timeline_apply_mode(model, mode, opts={}, push_state=true) {
|
||||
let xs;
|
||||
const { pubkey, thread_id } = opts;
|
||||
const el = view_get_timeline_el();
|
||||
|
@ -30,6 +39,10 @@ function view_timeline_apply_mode(model, mode, opts={}) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Push a new state to the browser history stack
|
||||
if (push_state)
|
||||
history.pushState({mode, opts}, '');
|
||||
|
||||
// Fetch history for certain views
|
||||
if (mode == VM_THREAD) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue