Skip to content

Commit

Permalink
Merge branch 'main' into uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
TrainDoctor authored Dec 16, 2023
2 parents 99cdcdb + 39f4f28 commit cc3b445
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 54 deletions.
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aiohttp==3.8.4
aiohttp==3.8.5
aiohttp-jinja2==1.5.1
aiohttp_cors==0.7.0
watchdog==2.1.7
Expand Down
12 changes: 12 additions & 0 deletions backend/src/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
else:
logger.fatal(f"Could not fetch from URL. {await res.text()}")

storeUrl = ""
match self.settings.getSetting("store", 0):
case 0: storeUrl = "https://plugins.deckbrew.xyz/plugins" # default
case 1: storeUrl = "https://testing.deckbrew.xyz/plugins" # testing
case 2: storeUrl = self.settings.getSetting("store-url", "https://plugins.deckbrew.xyz/plugins") # custom
case _: storeUrl = "https://plugins.deckbrew.xyz/plugins"
logger.info(f"Incrementing installs for {name} from URL {storeUrl} (version {version})")
async with ClientSession() as client:
res = await client.post(storeUrl+f"/{name}/versions/{version}/increment?isUpdate={isInstalled}", ssl=get_ssl_context())
if res.status != 200:
logger.error(f"Server did not accept install count increment request. code: {res.status}")

# Check to make sure we got the file
if res_zip is None:
logger.fatal(f"Could not fetch {artifact}")
Expand Down
26 changes: 24 additions & 2 deletions backend/src/localplatformlinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,22 @@ def chown(path : str, user : UserType = UserType.HOST_USER, recursive : bool =
def chmod(path : str, permissions : int, recursive : bool = True) -> bool:
if _get_effective_user_id() != 0:
return True
result = call(["chmod", "-R", str(permissions), path] if recursive else ["chmod", str(permissions), path])
return result == 0

try:
octal_permissions = int(str(permissions), 8)

if recursive:
for root, dirs, files in os.walk(path):
for d in dirs:
os.chmod(os.path.join(root, d), octal_permissions)
for d in files:
os.chmod(os.path.join(root, d), octal_permissions)

os.chmod(path, octal_permissions)
except:
return False

return True

def folder_owner(path : str) -> UserType|None:
user_owner = _get_user_owner(path)
Expand Down Expand Up @@ -125,11 +139,19 @@ async def service_restart(service_name : str) -> bool:
return res.returncode == 0

async def service_stop(service_name : str) -> bool:
if not await service_active(service_name):
# Service isn't running. pretend we stopped it
return True

cmd = ["systemctl", "stop", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0

async def service_start(service_name : str) -> bool:
if await service_active(service_name):
# Service is running. pretend we started it
return True

cmd = ["systemctl", "start", service_name]
res = run(cmd, stdout=PIPE, stderr=STDOUT)
return res.returncode == 0
Expand Down
1 change: 1 addition & 0 deletions backend/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ async def _on_new_message(self, message : str) -> str|None:
while get_event_loop().is_running():
await sleep(0)
get_event_loop().close()
await self._unload()
raise Exception("Closing message listener")

# TODO there is definitely a better way to type this
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
},
"dependencies": {
"decky-frontend-lib": "3.21.1",
"decky-frontend-lib": "3.24.1",
"filesize": "^10.0.7",
"i18next": "^23.2.1",
"i18next-http-backend": "^2.2.1",
Expand Down
14 changes: 7 additions & 7 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions frontend/src/components/PluginView.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
ButtonItem,
Focusable,
PanelSection,
PanelSectionRow,
joinClassNames,
scrollClasses,
staticClasses,
} from 'decky-frontend-lib';
import { ButtonItem, Focusable, PanelSection, PanelSectionRow } from 'decky-frontend-lib';
import { VFC, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaEyeSlash } from 'react-icons/fa';
Expand Down Expand Up @@ -36,10 +28,7 @@ const PluginView: VFC = () => {
return (
<Focusable onCancelButton={closeActivePlugin}>
<TitleView />
<div
className={joinClassNames(staticClasses.TabGroupPanel, scrollClasses.ScrollPanel, scrollClasses.ScrollY)}
style={{ height: '100%' }}
>
<div style={{ height: '100%', paddingTop: '16px' }}>
{(visible || activePlugin.alwaysRender) && activePlugin.content}
</div>
</Focusable>
Expand All @@ -48,7 +37,11 @@ const PluginView: VFC = () => {
return (
<>
<TitleView />
<div className={joinClassNames(staticClasses.TabGroupPanel, scrollClasses.ScrollPanel, scrollClasses.ScrollY)}>
<div
style={{
paddingTop: '16px',
}}
>
<PanelSection>
{pluginList
.filter((p) => p.content)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/TitleView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const titleStyles: CSSProperties = {
display: 'flex',
paddingTop: '3px',
paddingRight: '16px',
position: 'sticky',
top: '0px',
};

const TitleView: VFC = () => {
Expand Down
36 changes: 17 additions & 19 deletions frontend/src/developer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findModuleChild, sleep } from 'decky-frontend-lib';
import { sleep } from 'decky-frontend-lib';
import { FaReact } from 'react-icons/fa';

import Logger from './logger';
Expand All @@ -9,32 +9,30 @@ const logger = new Logger('DeveloperMode');

let removeSettingsObserver: () => void = () => {};

export async function setShowValveInternal(show: boolean) {
let settingsMod: any;
while (!settingsMod) {
settingsMod = findModuleChild((m) => {
if (typeof m !== 'object') return undefined;
for (let prop in m) {
if (typeof m[prop]?.settings?.bIsValveEmail !== 'undefined') return m[prop];
}
});
if (!settingsMod) {
logger.debug('[ValveInternal] waiting for settingsMod');
await sleep(1000);
}
declare global {
interface Window {
settingsStore: any;
}
}

export async function setShowValveInternal(show: boolean) {
if (show) {
removeSettingsObserver = settingsMod[
Object.getOwnPropertySymbols(settingsMod).find((x) => x.toString() == 'Symbol(mobx administration)') as any
].observe((e: any) => {
const mobx =
window.settingsStore[
Object.getOwnPropertySymbols(window.settingsStore).find(
(x) => x.toString() == 'Symbol(mobx administration)',
) as any
];

removeSettingsObserver = (mobx.observe_ || mobx.observe).call(mobx, (e: any) => {
e.newValue.bIsValveEmail = true;
});
settingsMod.m_Settings.bIsValveEmail = true;

window.settingsStore.m_Settings.bIsValveEmail = true;
logger.log('Enabled Valve Internal menu');
} else {
removeSettingsObserver();
settingsMod.m_Settings.bIsValveEmail = false;
window.settingsStore.m_Settings.bIsValveEmail = false;
logger.log('Disabled Valve Internal menu');
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tabs-hook.old.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TabsHook for versions before the Desktop merge
import { Patch, afterPatch, sleep } from 'decky-frontend-lib';
import { Patch, afterPatch, getReactRoot, sleep } from 'decky-frontend-lib';
import { memo } from 'react';

import NewTabsHook from './tabs-hook';
Expand Down Expand Up @@ -35,7 +35,7 @@ class TabsHook extends NewTabsHook {

init() {
const self = this;
const tree = (document.getElementById('root') as any)._reactRootContainer._internalRoot.current;
const tree = getReactRoot(document.getElementById('root') as any);
let scrollRoot: any;
async function findScrollRoot(currentNode: any, iters: number): Promise<any> {
if (iters >= 30) {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/tabs-hook.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TabsHook for versions after the Desktop merge
import { Patch, QuickAccessTab, afterPatch, findInReactTree, sleep } from 'decky-frontend-lib';
import { Patch, QuickAccessTab, afterPatch, findInReactTree, getReactRoot, sleep } from 'decky-frontend-lib';

import { QuickAccessVisibleStateProvider } from './components/QuickAccessVisibleState';
import Logger from './logger';
Expand Down Expand Up @@ -32,11 +32,11 @@ class TabsHook extends Logger {
}

init() {
const tree = (document.getElementById('root') as any)._reactRootContainer._internalRoot.current;
const tree = getReactRoot(document.getElementById('root') as any);
let qAMRoot: any;
const findQAMRoot = (currentNode: any, iters: number): any => {
if (iters >= 65) {
// currently 45
if (iters >= 80) {
// currently 67
return null;
}
if (
Expand Down
17 changes: 13 additions & 4 deletions frontend/src/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Module, Patch, ToastData, afterPatch, findInReactTree, findModuleChild, sleep } from 'decky-frontend-lib';
import {
Module,
Patch,
ToastData,
afterPatch,
findInReactTree,
findModuleChild,
getReactRoot,
sleep,
} from 'decky-frontend-lib';
import { ReactNode } from 'react';

import Toast from './components/Toast';
Expand Down Expand Up @@ -38,10 +47,10 @@ class Toaster extends Logger {
// </DeckyToasterStateContextProvider>
// ));
let instance: any;
const tree = (document.getElementById('root') as any)._reactRootContainer._internalRoot.current;
const tree = getReactRoot(document.getElementById('root') as any);
const findToasterRoot = (currentNode: any, iters: number): any => {
if (iters >= 65) {
// currently 65
if (iters >= 80) {
// currently 66
return null;
}
if (
Expand Down

0 comments on commit cc3b445

Please sign in to comment.