Skip to content

Commit b470716

Browse files
[RandomButton] Correct random sort logic (#650)
Co-authored-by: DogmaDragon <[email protected]>
1 parent c10e0d2 commit b470716

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

plugins/StashRandomButton/random_button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
async function randomGlobal(entity, idField, redirectPrefix, internalFilter) {
2121
const realEntityPlural = getPlural(entity);
22-
let filter = { per_page: 1 };
22+
let filter = { per_page: 1, sort: "random" };
2323
let variables = { filter };
2424
let filterArg = "";
2525
let filterVar = "";
@@ -45,7 +45,7 @@
4545
if (!totalCount) { alert("No results found."); return; }
4646

4747
const randomIndex = Math.floor(Math.random() * totalCount);
48-
let itemVars = { filter: { per_page: 1, page: randomIndex + 1 } };
48+
let itemVars = { filter: { per_page: 1, page: randomIndex + 1, sort: "random" } };
4949
if (internalFilter) itemVars.internal_filter = internalFilter;
5050
const itemQuery = `
5151
query Find${realEntityPlural}($filter: FindFilterType${filterArg}) {

plugins/StashRandomButton/random_button.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: RandomButton
22
description: Adds a button to quickly jump to a random scene, image, performer, studio, group, tag, or gallery, both on overview and internal entity pages.
3-
version: 2.0.1
3+
version: 2.0.2
44
url: https://discourse.stashapp.cc/t/randombutton/1809
55
ui:
66
requires: []

0 commit comments

Comments
 (0)