fix updater for new installs, fix file picker patch, fix scrolling on patch notes, fix tasks dir

This commit is contained in:
AAGaming
2022-09-17 23:23:51 -04:00
parent fded2fa8bf
commit c4d6731401
8 changed files with 113 additions and 44 deletions
@@ -86,7 +86,8 @@ const FilePicker: FunctionComponent<FilePickerProps> = ({
onClick={() => {
const newPathArr = path.split('/');
newPathArr.pop();
const newPath = newPathArr.join('/');
let newPath = newPathArr.join('/');
if (newPath == '') newPath = '/';
setPath(newPath);
}}
>
@@ -113,7 +114,7 @@ const FilePicker: FunctionComponent<FilePickerProps> = ({
<DialogButton
style={{ borderRadius: 'unset', margin: '0', padding: '10px' }}
onClick={() => {
const fullPath = `${path}/${file.name}`;
const fullPath = `${path}${path.endsWith('/') ? '' : '/'}${file.name}`;
if (file.isdir) setPath(fullPath);
else {
onSubmit({ path: fullPath, realpath: file.realpath });
@@ -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() {
});
}
export default async function libraryPatch() {
await sleep(10000);
rePatch();
await sleep(10000);
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;
}
});
return () => {
patch.unpatch();
};
export default async function libraryPatch() {
try {
rePatch();
const unlisten = History.listen(() => {
if (window.SteamClient.Apps.PromptToChangeShortcut !== patch.patchedFunction) {
rePatch();
}
});
return () => {
patch.unpatch();
unlisten();
};
} catch (e) {
console.error('Error patching library file picker', e);
}
return () => {};
}