Add List Sort Filter plugin - #748
Open
suzuhiroruri wants to merge 1 commit into
Open
Conversation
Trims the "sort by" dropdown of each list down to the options the user actually uses: unticking an entry stops it appearing in that list's menu. Display only, so saved filters and ?sortby= URLs keep working. The plugin carries no list of sort values and no labels of its own. Each list's options are read from the filter Stash hands its list components (PluginApi.patch.before on SceneList, PerformerList, ...), and labelled by formatting Stash's own message IDs through PluginApi.libraries.Intl, so no update is needed when Stash changes its sort options or the UI language changes. Entries are hidden with generated CSS against the data-value attribute Stash already renders; each list's rules are anchored on a sort value unique to it, so values that share a name across lists never leak. Settings are drawn by patching PluginSettings and built from Stash's own SettingGroup / BooleanSetting, since static YAML settings would mean a fixed checkbox per sort option to maintain. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trims the sort by dropdown of each list down to the options you actually use. Untick an entry and it stops appearing in that list's menu.
Stash offers 30 sort options for scenes, 23 for performers, 13 for tags, and so on; most libraries only ever use a handful.
Nothing is hidden until you tick it — installing the plugin changes nothing on its own.
Display only
Only the menu entry is hidden; sorting itself is untouched. Saved filters keep working even when they sort by a hidden entry,
?sortby=play_countURLs keep working, and the dropdown button still shows the current sort by name. Hiding an entry cannot break an existing view.No hard-coded sort options
The plugin carries no list of sort values and no labels of its own:
PluginApi.patch.beforeonSceneList,PerformerList, …), read as the page renders — no interaction, nothing parsed;PluginApi.libraries.Intl, so the settings page matches the dropdown word for word and follows a UI language change immediately;So when Stash adds, removes or renames a sort option, the plugin needs no update. The only Stash names it knows are the eight list component names, which is API surface rather than data.
Hiding
Stash renders every sort entry with a
data-valueattribute, so the hiding is generated CSS — no DOM rewriting of the menus, no patching of the dropdown:ANCHORis a sort value that occurs in that list and in no other;HIDDENis an entry the user unticked.Lists are keyed by the mode Stash uses (
SCENES,PERFORMERS, …), but a stylesheet cannot know which list a menu belongs to and the DOM does not say — the performer list carries the classgallery-list, same as the gallery list, and/performers/42/scenesis a scene list on a performer route. So each list's rules are anchored on a value unique to it, computed from the lists seen so far. Values that share a name across lists (rating,path,tag_count,duration, …) therefore never leak, and lists embedded in performer/studio/tag pages are covered without any route matching. Browsers without:has()fall back to a small MutationObserver that stamps each menu with its mode.Settings
Stash's plugin settings are static YAML, so a fixed checkbox per sort option would be exactly the thing that needs maintaining whenever Stash changes one. The plugin declares only a master switch plus two JSON values for its own storage, and draws the per-entry checkboxes itself by patching
PluginSettings— built from Stash's ownSettingGroupandBooleanSetting, so it inherits the native look and the collapsing rather than reimplementing them. A list appears there once you have opened it.Its own handful of sentences are translated for every language Stash offers (38 tables, falling back to English per string). Those are best-effort — corrections from native speakers are very welcome.
Testing
Checked against Stash v0.31.1 (Japanese UI):
node validate.jspasses.