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) {
|
||||
//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(
|
||||
uri.formatApiLink(
|
||||
'posts', {
|
||||
|
@ -24,6 +28,7 @@ class PostList extends AbstractList {
|
|||
offset: offset,
|
||||
limit: limit,
|
||||
fields: fields.join(','),
|
||||
cache: cache,
|
||||
}))
|
||||
.then(response => {
|
||||
return Promise.resolve(Object.assign(
|
||||
|
|
|
@ -248,10 +248,9 @@ class PostsHeaderView extends events.EventTarget {
|
|||
this._navigate();
|
||||
}
|
||||
_evtRandomButtonClick(e) {
|
||||
e.preventDefault();
|
||||
if (!this._queryInputNode.value.includes('sort:random')) {
|
||||
this._queryInputNode.value += ' sort:random';
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
this._navigate();
|
||||
}
|
||||
|
|
Reference in a new issue