summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-09-16 18:49:35 -0400
committerAAGaming <aa@mail.catvibers.me>2022-09-16 18:49:35 -0400
commit463258febbb67bf866b107bed2417a100f6eade3 (patch)
treec89aa0354b608d46d34705fef0b835204c918f50
parent304fc0f94c7e558e11ff17787ce8b5944de15474 (diff)
downloaddecky-loader-463258febbb67bf866b107bed2417a100f6eade3.tar.gz
decky-loader-463258febbb67bf866b107bed2417a100f6eade3.zip
wait for toaster ready, hopefully fix file browser patch
-rw-r--r--frontend/src/components/modals/filepicker/patches/library.ts18
-rw-r--r--frontend/src/toaster.tsx7
2 files changed, 20 insertions, 5 deletions
diff --git a/frontend/src/components/modals/filepicker/patches/library.ts b/frontend/src/components/modals/filepicker/patches/library.ts
index 8792900d..7ba977a5 100644
--- a/frontend/src/components/modals/filepicker/patches/library.ts
+++ b/frontend/src/components/modals/filepicker/patches/library.ts
@@ -1,4 +1,4 @@
-import { replacePatch, sleep } from 'decky-frontend-lib';
+import { Patch, replacePatch, sleep } from 'decky-frontend-lib';
declare global {
interface Window {
@@ -7,9 +7,12 @@ declare global {
}
}
-export default async function libraryPatch() {
- await sleep(10000); // If you patch anything on SteamClient within the first few seconds of the client having loaded it will get redefined for some reason, so wait 10s
- const patch = replacePatch(window.SteamClient.Apps, 'PromptToChangeShortcut', async ([appid]: number[]) => {
+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();
+ patch = replacePatch(window.SteamClient.Apps, 'PromptToChangeShortcut', async ([appid]: number[]) => {
try {
const details = window.appDetailsStore.GetAppDetails(appid);
console.log(details);
@@ -25,6 +28,13 @@ export default async function libraryPatch() {
console.error(e);
}
});
+}
+
+export default async function libraryPatch() {
+ await sleep(10000);
+ rePatch();
+ await sleep(10000);
+ rePatch();
return () => {
patch.unpatch();
diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx
index 3a922bfc..5590e43c 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/toaster.tsx
@@ -15,6 +15,7 @@ class Toaster extends Logger {
private instanceRetPatch?: Patch;
private node: any;
private settingsModule: any;
+ private ready: boolean = false;
constructor() {
super('Toaster');
@@ -72,9 +73,13 @@ class Toaster extends Logger {
};
this.node.stateNode.forceUpdate();
this.log('Initialized');
+ this.ready = true;
}
- toast(toast: ToastData) {
+ async toast(toast: ToastData) {
+ while (!this.ready) {
+ await sleep(100);
+ }
const settings = this.settingsModule.settings;
let toastData = {
nNotificationID: window.NotificationStore.m_nNextTestNotificationID++,