Merge 5d96e0e787
into 6a95a66f12
This commit is contained in:
commit
95d3ebd4af
4 changed files with 21 additions and 1 deletions
|
@ -4,6 +4,9 @@
|
||||||
%><wbr/><%
|
%><wbr/><%
|
||||||
%><input class='mousetrap' type='submit' value='Search'/><%
|
%><input class='mousetrap' type='submit' value='Search'/><%
|
||||||
%><wbr/><%
|
%><wbr/><%
|
||||||
|
%><button id="random-button" style="padding:0.2em; margin-right:0.25em; margin-bottom:0.25em;"><%
|
||||||
|
%><i class="fa fa-random" style="vertical-align: middle"><%
|
||||||
|
%></button><%
|
||||||
%><% if (ctx.enableSafety) { %><%
|
%><% if (ctx.enableSafety) { %><%
|
||||||
%><input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/><%
|
%><input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/><%
|
||||||
%><input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/><%
|
%><input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/><%
|
||||||
|
|
|
@ -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 != null && 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(
|
||||||
|
|
|
@ -145,6 +145,7 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
'click', e => this._evtSafetyButtonClick(e));
|
'click', e => this._evtSafetyButtonClick(e));
|
||||||
}
|
}
|
||||||
this._formNode.addEventListener('submit', e => this._evtFormSubmit(e));
|
this._formNode.addEventListener('submit', e => this._evtFormSubmit(e));
|
||||||
|
this._randomButtonNode.addEventListener('click', e => this._evtRandomButtonClick(e));
|
||||||
|
|
||||||
this._bulkEditors = [];
|
this._bulkEditors = [];
|
||||||
if (this._bulkEditTagsNode) {
|
if (this._bulkEditTagsNode) {
|
||||||
|
@ -191,6 +192,10 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
return this._hostNode.querySelector('form [name=search-text]');
|
return this._hostNode.querySelector('form [name=search-text]');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _randomButtonNode() {
|
||||||
|
return this._hostNode.querySelector('#random-button');
|
||||||
|
}
|
||||||
|
|
||||||
get _bulkEditTagsNode() {
|
get _bulkEditTagsNode() {
|
||||||
return this._hostNode.querySelector('.bulk-edit-tags');
|
return this._hostNode.querySelector('.bulk-edit-tags');
|
||||||
}
|
}
|
||||||
|
@ -242,6 +247,13 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this._navigate();
|
this._navigate();
|
||||||
}
|
}
|
||||||
|
_evtRandomButtonClick(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!this._queryInputNode.value.includes('sort:random')) {
|
||||||
|
this._queryInputNode.value += ' sort:random';
|
||||||
|
}
|
||||||
|
this._navigate();
|
||||||
|
}
|
||||||
|
|
||||||
_navigate() {
|
_navigate() {
|
||||||
this._autoCompleteControl.hide();
|
this._autoCompleteControl.hide();
|
||||||
|
|
|
@ -94,7 +94,7 @@ class Executor:
|
||||||
disable_eager_loads = True
|
disable_eager_loads = True
|
||||||
|
|
||||||
key = (id(self.config), hash(search_query), offset, limit)
|
key = (id(self.config), hash(search_query), offset, limit)
|
||||||
if cache.has(key):
|
if not disable_eager_loads and cache.has(key):
|
||||||
return cache.get(key)
|
return cache.get(key)
|
||||||
|
|
||||||
filter_query = self.config.create_filter_query(disable_eager_loads)
|
filter_query = self.config.create_filter_query(disable_eager_loads)
|
||||||
|
|
Reference in a new issue