diff --git a/package.json b/package.json index c5c9b9b..916a9d4 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "typescript": "^4.8.4" }, "dependencies": { - "decky-frontend-lib": "^3.6.1", + "decky-frontend-lib": "^3.18.10", "localforage": "^1.10.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a67e5b7..81e492e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,7 +11,7 @@ specifiers: '@types/webpack': ^5.28.0 '@typescript-eslint/eslint-plugin': ^5.40.1 '@typescript-eslint/parser': ^5.40.1 - decky-frontend-lib: ^3.6.1 + decky-frontend-lib: ^3.18.10 eslint: ^8.26.0 eslint-config-prettier: ^8.5.0 eslint-plugin-prettier: ^4.2.1 @@ -27,7 +27,7 @@ specifiers: typescript: ^4.8.4 dependencies: - decky-frontend-lib: 3.6.1 + decky-frontend-lib: 3.18.10 localforage: 1.10.0 react: 18.2.0 react-dom: 18.2.0_react@18.2.0 @@ -744,10 +744,8 @@ packages: ms: 2.1.2 dev: true - /decky-frontend-lib/3.6.1: - resolution: {integrity: sha512-NBlltn4EktqFgD1fj2AU0ccJJNMNgcqCnmhYd34Z5xR7ypGNT2oSqfSvFIlzU4WbDL9RyrcHSJlSMdYk6n4NXA==} - dependencies: - minimist: 1.2.6 + /decky-frontend-lib/3.18.10: + resolution: {integrity: sha512-2mgbA3sSkuwQR/FnmhXVrcW6LyTS95IuL6muJAmQCruhBvXapDtjk1TcgxqMZxFZwGD1IPnemPYxHZll6IgnZw==} dev: false /deep-is/0.1.4: @@ -1331,6 +1329,7 @@ packages: /minimist/1.2.6: resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} + dev: true /ms/2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} diff --git a/src/components/protonMedal/index.tsx b/src/components/protonMedal/index.tsx index 571a349..9f1bb1d 100644 --- a/src/components/protonMedal/index.tsx +++ b/src/components/protonMedal/index.tsx @@ -1,4 +1,4 @@ -import { Router, ServerAPI } from 'decky-frontend-lib' +import { Navigation, ServerAPI } from 'decky-frontend-lib' import { ReactElement, FC, CSSProperties, ReactNode } from 'react' import { FaReact } from 'react-icons/fa' import { IoLogoTux } from 'react-icons/io' @@ -60,7 +60,7 @@ export default function ProtonMedal({ type="button" onClick={async () => { refresh() - Router.NavigateToExternalWeb(`https://www.protondb.com/app/${appId}`) + Navigation.NavigateToExternalWeb(`https://www.protondb.com/app/${appId}`) }} style={{ ...positonSettings[state.position] diff --git a/src/lib/patchLibraryApp.tsx b/src/lib/patchLibraryApp.tsx index 61c577b..1a990f8 100644 --- a/src/lib/patchLibraryApp.tsx +++ b/src/lib/patchLibraryApp.tsx @@ -1,4 +1,10 @@ -import { afterPatch, ServerAPI, wrapReactType } from 'decky-frontend-lib' +import { + afterPatch, + ServerAPI, + wrapReactType, + findInReactTree, + appDetailsClasses +} from 'decky-frontend-lib' import { ReactElement } from 'react' import ProtonMedal from '../components/protonMedal' import { SettingsProvider } from '../context/settingsContext' @@ -6,34 +12,47 @@ import { SettingsProvider } from '../context/settingsContext' function patchLibraryApp(serverAPI: ServerAPI) { return serverAPI.routerHook.addPatch( '/library/app/:appid', - (props: { path: string; children: ReactElement }) => { + (props?: { path?: string; children?: ReactElement }) => { + if (!props?.children?.props?.renderFunc) { + return props + } + afterPatch( props.children.props, 'renderFunc', - (_: Record[], ret: ReactElement) => { + (_: Record[], ret?: ReactElement) => { + if (!ret?.props?.children?.type?.type) { + return ret + } + wrapReactType(ret.props.children) afterPatch( ret.props.children.type, 'type', - (_2: Record[], ret2: ReactElement) => { - const alreadySpliced = Boolean( - ret2.props?.children?.[1]?.props.children.props.children.find( - (child: ReactElement) => - child?.props?.className === 'protondb-decky-indicator' - ) + (_2: Record[], ret2?: ReactElement) => { + const container = findInReactTree( + ret2, + (x: any) => + Array.isArray(x?.props?.children) && + x?.props?.className?.includes( + appDetailsClasses.InnerContainer + ) ) - if (!alreadySpliced) { - ret2.props.children?.[1]?.props.children.props.children.splice( - 1, - 0, - - - - ) + if (typeof container !== 'object') { + return ret2 } + + container.props.children.splice( + 1, + 0, + + + + ) + return ret2 } )