Don't cache urls with 'sort:random'.
No need to refresh the page for the same url now.
This commit is contained in:
parent
1032104f88
commit
86d0c4086b
2 changed files with 6 additions and 2 deletions
|
@ -17,6 +17,10 @@ class PostList extends AbstractList {
|
||||||
}
|
}
|
||||||
|
|
||||||
static search(text, offset, limit, fields) {
|
static search(text, offset, limit, fields) {
|
||||||
|
//For queries with random sorting, bypass cache by appending random number
|
||||||
|
let cache = text.includes('sort:random')
|
||||||
|
? Math.round(Math.random() * 1000)
|
||||||
|
: 0;
|
||||||
return api.get(
|
return api.get(
|
||||||
uri.formatApiLink(
|
uri.formatApiLink(
|
||||||
'posts', {
|
'posts', {
|
||||||
|
@ -24,6 +28,7 @@ class PostList extends AbstractList {
|
||||||
offset: offset,
|
offset: offset,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
fields: fields.join(','),
|
fields: fields.join(','),
|
||||||
|
cache: cache,
|
||||||
}))
|
}))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return Promise.resolve(Object.assign(
|
return Promise.resolve(Object.assign(
|
||||||
|
|
|
@ -248,10 +248,9 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
this._navigate();
|
this._navigate();
|
||||||
}
|
}
|
||||||
_evtRandomButtonClick(e) {
|
_evtRandomButtonClick(e) {
|
||||||
|
e.preventDefault();
|
||||||
if (!this._queryInputNode.value.includes('sort:random')) {
|
if (!this._queryInputNode.value.includes('sort:random')) {
|
||||||
this._queryInputNode.value += ' sort:random';
|
this._queryInputNode.value += ' sort:random';
|
||||||
} else {
|
|
||||||
location.reload();
|
|
||||||
}
|
}
|
||||||
this._navigate();
|
this._navigate();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue