Files
Pierre Kisters 4c843c3ce4 Patch headers and comments: concise
Document the patch calling convention once in lib/default.nix; patch
headers say what, target, hook, state and contracts. Comments only, no
code changes.
2026-09-27 23:57:50 +02:00

26 lines
1.2 KiB
JavaScript

// order: sorts the VR dashboard's "+" menu alphabetically (case-insensitive),
// Desktop included. Steam shows ScanForInstalledNonSteamApps() in GLib
// hash-table order and looks the function up at call time, so wrapping it in
// SharedJSContext suffices. Original kept as __sfuiOrig for unpatch.js; bump
// VERSION on changes.
(() => {
const VERSION = 3;
const NAME = 'launcher-menu-order';
const Apps = window.SteamClient?.Apps;
const cur = Apps?.ScanForInstalledNonSteamApps;
if (typeof cur !== 'function') return 'SteamClient.Apps.ScanForInstalledNonSteamApps missing';
if (cur.__sfuiPatch === NAME && cur.__sfuiVersion === VERSION) return 'unchanged';
const orig = cur.__sfuiPatch === NAME ? cur.__sfuiOrig : cur;
const name = (a) => String(a?.strAppName ?? '');
const sort = (list) => Array.isArray(list)
? [...list].sort((a, b) => name(a).localeCompare(name(b), undefined, { sensitivity: 'base' }))
: list;
const f = function ScanForInstalledNonSteamApps(...args) {
return Promise.resolve(orig.apply(this, args)).then(sort);
};
f.__sfuiPatch = NAME; f.__sfuiVersion = VERSION; f.__sfuiOrig = orig;
Apps.ScanForInstalledNonSteamApps = f;
return 'patched';
})()