simplify search history state handling
This commit is contained in:
parent
bbbd23c842
commit
01ffb052e6
@ -74,7 +74,6 @@ class DisplaySearch extends Display {
|
|||||||
query = window.wanakana.toKana(query);
|
query = window.wanakana.toKana(query);
|
||||||
}
|
}
|
||||||
this.query.value = query;
|
this.query.value = query;
|
||||||
window.history.replaceState({query}, '');
|
|
||||||
this.onSearchQueryUpdated(query, false);
|
this.onSearchQueryUpdated(query, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,16 +129,12 @@ class DisplaySearch extends Display {
|
|||||||
|
|
||||||
const query = this.query.value;
|
const query = this.query.value;
|
||||||
const queryString = query.length > 0 ? `?query=${encodeURIComponent(query)}` : '';
|
const queryString = query.length > 0 ? `?query=${encodeURIComponent(query)}` : '';
|
||||||
window.history.pushState({query}, '', `${window.location.pathname}${queryString}`);
|
window.history.pushState(null, '', `${window.location.pathname}${queryString}`);
|
||||||
this.onSearchQueryUpdated(query, true);
|
this.onSearchQueryUpdated(query, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPopState(e) {
|
onPopState(e) {
|
||||||
let query = '';
|
const query = DisplaySearch.getSearchQueryFromLocation(window.location.href) || '';
|
||||||
if (e.state && e.state.query) {
|
|
||||||
query = e.state.query
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.query !== null) {
|
if (this.query !== null) {
|
||||||
this.query.value = query;
|
this.query.value = query;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user