summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/filepicker/patches/library.ts
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-09-17 23:23:51 -0400
committerAAGaming <aa@mail.catvibers.me>2022-09-17 23:23:51 -0400
commitc4d6731401d3b6dc111a74d086df28704473070d (patch)
treeb8a1cff3ae32eac720300fd03093f9890ddf82cb /frontend/src/components/modals/filepicker/patches/library.ts
parentfded2fa8bfc52ae29848a343483c68f6955feb0c (diff)
downloaddecky-loader-c4d6731401d3b6dc111a74d086df28704473070d.tar.gz
decky-loader-c4d6731401d3b6dc111a74d086df28704473070d.zip
fix updater for new installs, fix file picker patch, fix scrolling on patch notes, fix tasks dir
Diffstat (limited to 'frontend/src/components/modals/filepicker/patches/library.ts')
-rw-r--r--frontend/src/components/modals/filepicker/patches/library.ts35
1 files changed, 25 insertions, 10 deletions
diff --git a/frontend/src/components/modals/filepicker/patches/library.ts b/frontend/src/components/modals/filepicker/patches/library.ts
index 7ba977a5..c9c7d53c 100644
--- a/frontend/src/components/modals/filepicker/patches/library.ts
+++ b/frontend/src/components/modals/filepicker/patches/library.ts
@@ -1,4 +1,4 @@
-import { Patch, replacePatch, sleep } from 'decky-frontend-lib';
+import { Patch, findModuleChild, replacePatch } from 'decky-frontend-lib';
declare global {
interface Window {
@@ -10,8 +10,7 @@ declare global {
let patch: Patch;
function rePatch() {
- // If you patch anything on SteamClient within the first few seconds of the client having loaded it will get redefined for some reason, so repatch any of these changes that occur within the first minute of the client loading
- patch?.unpatch();
+ // If you patch anything on SteamClient within the first few seconds of the client having loaded it will get redefined for some reason, so repatch any of these changes that occur within the first 20s of the last patch
patch = replacePatch(window.SteamClient.Apps, 'PromptToChangeShortcut', async ([appid]: number[]) => {
try {
const details = window.appDetailsStore.GetAppDetails(appid);
@@ -30,13 +29,29 @@ function rePatch() {
});
}
+// TODO type and add to frontend-lib
+const History = findModuleChild((m) => {
+ if (typeof m !== 'object') return undefined;
+ for (let prop in m) {
+ if (m[prop]?.m_history) return m[prop].m_history;
+ }
+});
+
export default async function libraryPatch() {
- await sleep(10000);
- rePatch();
- await sleep(10000);
- rePatch();
+ try {
+ rePatch();
+ const unlisten = History.listen(() => {
+ if (window.SteamClient.Apps.PromptToChangeShortcut !== patch.patchedFunction) {
+ rePatch();
+ }
+ });
- return () => {
- patch.unpatch();
- };
+ return () => {
+ patch.unpatch();
+ unlisten();
+ };
+ } catch (e) {
+ console.error('Error patching library file picker', e);
+ }
+ return () => {};
}