Skip to content

Commit

Permalink
Merge pull request #100 from suchmememanyskill/dev
Browse files Browse the repository at this point in the history
V2.0.1
  • Loading branch information
beebls committed Sep 29, 2023
2 parents b2b10f9 + eda30bc commit d394112
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 25 deletions.
6 changes: 3 additions & 3 deletions css_browserhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, browserHook, sessionId : str, targetInfo : dict):
asyncio.create_task(self._init())

async def _init(self):
res = await self.evaluate_js("(function(){ return {\"title\": document.title, \"classes\": Array.from(document.documentElement.classList)} })()")
res = await self.evaluate_js("(function(){ return {\"title\": document.title, \"classes\": Array.from(document.documentElement.classList).concat(Array.from(document.body.classList)).concat(Array.from(document.head.classList))} })()")

if res != None:
self.title = res["title"]
Expand Down Expand Up @@ -472,8 +472,8 @@ async def remove(tab_name : str, css_id : str) -> Result:

return Result(True)

async def commit_all():
await asyncio.gather(*[x.commit_css_transaction() for x in HOOK.connected_tabs])
async def commit_all(remove_all_first : bool = False):
await asyncio.gather(*[x.commit_css_transaction(remove_all_first=remove_all_first) for x in HOOK.connected_tabs])

async def remove_all():
await asyncio.gather(*[x.remove_all_css() for x in HOOK.connected_tabs])
12 changes: 8 additions & 4 deletions css_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ async def set_component_of_theme_patch(self, themeName : str, patchName : str, c
await commit_all()
return Result(True)

async def reset(self) -> dict:
async def reset(self, silent : bool = False) -> dict:
await self.lock()
try:
await remove_all()
await self.load()
await commit_all()
if silent:
await self.load()
await commit_all(remove_all_first=True)
else:
await remove_all()
await self.load()
await commit_all()
except Exception as e:
await self.unlock()
Result(False, str(e))
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def on_modified(self, event):
if ((self.last + self.delay) < time.time() and not self.loader.busy):
self.last = time.time()
Log("Reloading themes due to FS event")
self.loop.create_task(self.loader.reset())
self.loop.create_task(self.loader.reset(silent=True))


class Plugin:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SDH-CssLoader",
"version": "2.0.0",
"version": "2.0.1",
"description": "A css loader",
"scripts": {
"build": "shx rm -rf dist && rollup -c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export function ThemeSettingsModalButtons({
starred: boolean;
};
if (data) {
console.log("DATA", data);
setStarFetchLoaded(true);
setStarred(data.starred);
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/TitleView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export function TitleView({ onDocsClick }: { onDocsClick?: () => {} }) {
Navigation.Navigate("/cssloader/theme-manager");
};

console.log("HEELO WUMPUS", onDocsClick);

return (
<Focusable
style={{
Expand Down
7 changes: 6 additions & 1 deletion src/deckyPatches/NavPatch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { replacePatch } from "decky-frontend-lib";
import { NavController } from "./NavControllerFinder";
import { globalState, toast } from "../python";
import { globalState, toast, storeWrite } from "../python";

export function enableNavPatch() {
const setGlobalState = globalState!.setGlobalState.bind(globalState);
Expand Down Expand Up @@ -40,3 +40,8 @@ export function disableNavPatch() {
toast("CSS Loader", "Nav Patch Disabled");
return;
}

export function setNavPatch(value: boolean) {
value ? enableNavPatch() : disableNavPatch();
storeWrite("enableNavPatch", value + "");
}
6 changes: 3 additions & 3 deletions src/deckyPatches/NavPatchInfoModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DialogButton, Focusable, ConfirmModal } from "decky-frontend-lib";
import { Theme } from "../ThemeTypes";
import { disableNavPatch, enableNavPatch } from "./NavPatch";
import { setNavPatch } from "./NavPatch";
export function NavPatchInfoModalRoot({
themeData,
closeModal,
Expand All @@ -9,7 +9,7 @@ export function NavPatchInfoModalRoot({
closeModal?: any;
}) {
function onButtonClick() {
enableNavPatch();
setNavPatch(true);
closeModal();
}
return (
Expand All @@ -21,4 +21,4 @@ export function NavPatchInfoModalRoot({
</span>
</ConfirmModal>
);
}
}
10 changes: 1 addition & 9 deletions src/pages/settings/PluginSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Focusable, ToggleField } from "decky-frontend-lib";
import { useMemo, useState, useEffect } from "react";
import { useCssLoaderState } from "../../state";
import { storeWrite } from "../../python";
import { disableNavPatch, enableNavPatch } from "../../deckyPatches/NavPatch";
import { setNavPatch } from "../../deckyPatches/NavPatch";
import {
getWatchState,
getServerState,
Expand All @@ -17,11 +17,6 @@ export function PluginSettings() {

const navPatchEnabled = useMemo(() => !!navPatchInstance, [navPatchInstance]);

function setNavPatch(value: boolean) {
value ? enableNavPatch() : disableNavPatch();
storeWrite("enableNavPatch", value + "");
}

useEffect(() => {
getServerState().then((res) => {
if (res.success) {
Expand All @@ -40,11 +35,8 @@ export function PluginSettings() {
}, []);

async function setWatch(enabled: boolean) {
console.log("VALUE", enabled);
await toggleWatchState(enabled, false);
console.log("TOGGLED");
const res = await getWatchState();
console.log("RES FETCHED", res);
if (res.success && res.result) setWatchOn(res.result);
}

Expand Down

0 comments on commit d394112

Please sign in to comment.