mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-06 17:59:54 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bebe9428a6 | |||
| 7445f066ed | |||
| 6e48aefce8 | |||
| 0bc0a0dadb |
+1
-1
@@ -7,7 +7,7 @@ if hasattr(sys, '_MEIPASS'):
|
||||
from asyncio import get_event_loop, sleep
|
||||
from json import dumps, loads
|
||||
from logging import DEBUG, INFO, basicConfig, getLogger
|
||||
from os import getenv, chmod
|
||||
from os import getenv, chmod, path
|
||||
from traceback import format_exc
|
||||
|
||||
import aiohttp_cors
|
||||
|
||||
@@ -32,7 +32,7 @@ const Toast: FunctionComponent<ToastProps> = ({ toast }) => {
|
||||
return (
|
||||
<div
|
||||
style={{ '--toast-duration': `${toast.nToastDurationMS}ms` } as React.CSSProperties}
|
||||
className={toastClasses.toastEnter}
|
||||
className={joinClassNames(toastClasses.ToastPopup, toastClasses.toastEnter)}
|
||||
>
|
||||
<div
|
||||
onClick={toast.data.onClick}
|
||||
|
||||
@@ -4,9 +4,6 @@ import {
|
||||
Patch,
|
||||
QuickAccessTab,
|
||||
Router,
|
||||
callOriginal,
|
||||
findModuleChild,
|
||||
replacePatch,
|
||||
showModal,
|
||||
sleep,
|
||||
staticClasses,
|
||||
@@ -97,38 +94,6 @@ class PluginLoader extends Logger {
|
||||
initFilepickerPatches();
|
||||
|
||||
this.updateVersion();
|
||||
|
||||
const self = this;
|
||||
|
||||
try {
|
||||
// TODO remove all of this once Valve fixes the bug
|
||||
const focusManager = findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return false;
|
||||
for (let prop in m) {
|
||||
if (m[prop]?.prototype?.TakeFocus) return m[prop];
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.focusWorkaroundPatch = replacePatch(focusManager.prototype, 'TakeFocus', function () {
|
||||
// @ts-ignore
|
||||
const classList = this.m_node?.m_element.classList;
|
||||
if (
|
||||
// @ts-ignore
|
||||
(this.m_node?.m_element && classList.contains(staticClasses.TabGroupPanel)) ||
|
||||
classList.contains('FriendsListTab') ||
|
||||
classList.contains('FriendsTabList') ||
|
||||
classList.contains('FriendsListAndChatsSteamDeck')
|
||||
) {
|
||||
self.debug('Intercepted friends re-focus');
|
||||
return true;
|
||||
}
|
||||
|
||||
return callOriginal;
|
||||
});
|
||||
} catch (e) {
|
||||
this.error('Friends focus patch failed', e);
|
||||
}
|
||||
}
|
||||
|
||||
public async updateVersion() {
|
||||
|
||||
+29
-14
@@ -38,23 +38,38 @@ class Toaster extends Logger {
|
||||
await sleep(2000);
|
||||
}
|
||||
|
||||
this.node = instance.sibling.child;
|
||||
this.node = instance.return.return;
|
||||
let toast: any;
|
||||
let renderedToast: ReactNode = null;
|
||||
afterPatch(this.node, 'type', (args: any[], ret: any) => {
|
||||
const currentToast = args[0].notification;
|
||||
if (currentToast?.decky) {
|
||||
if (currentToast !== toast) {
|
||||
toast = currentToast;
|
||||
renderedToast = <Toast toast={toast} />;
|
||||
}
|
||||
ret.props.children = renderedToast;
|
||||
} else {
|
||||
toast = null;
|
||||
renderedToast = null;
|
||||
this.node.stateNode.render = (...args: any[]) => {
|
||||
const ret = this.node.stateNode.__proto__.render.call(this.node.stateNode, ...args);
|
||||
if (ret) {
|
||||
this.instanceRetPatch = afterPatch(ret, 'type', (_: any, ret: any) => {
|
||||
if (ret?.props?.children[1]?.children?.props) {
|
||||
const currentToast = ret.props.children[1].children.props.notification;
|
||||
if (currentToast?.decky) {
|
||||
if (currentToast == toast) {
|
||||
ret.props.children[1].children = renderedToast;
|
||||
} else {
|
||||
toast = currentToast;
|
||||
renderedToast = <Toast toast={toast} />;
|
||||
ret.props.children[1].children = renderedToast;
|
||||
}
|
||||
} else {
|
||||
toast = null;
|
||||
renderedToast = null;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
this.node.stateNode.shouldComponentUpdate = () => {
|
||||
return false;
|
||||
};
|
||||
delete this.node.stateNode.render;
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
};
|
||||
this.node.stateNode.forceUpdate();
|
||||
this.settingsModule = findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
for (let prop in m) {
|
||||
@@ -91,7 +106,7 @@ class Toaster extends Logger {
|
||||
|
||||
deinit() {
|
||||
this.instanceRetPatch?.unpatch();
|
||||
this.node && delete this.node.stateNode.render;
|
||||
this.node && delete this.node.stateNode.shouldComponentUpdate;
|
||||
this.node && this.node.stateNode.forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user