diff --git a/backend/Cargo.lock b/backend/Cargo.lock index a2f06f9..dc737ff 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1170,7 +1170,7 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "powertools" -version = "2.0.0-alpha3" +version = "2.0.0-alpha4" dependencies = [ "async-trait", "chrono", @@ -1295,6 +1295,20 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.48.0", +] + [[package]] name = "ron" version = "0.8.1" @@ -1332,6 +1346,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.21.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -1341,6 +1367,16 @@ dependencies = [ "base64 0.21.5", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.16" @@ -1353,6 +1389,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "serde" version = "1.0.193" @@ -1738,6 +1784,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "ureq" version = "2.9.1" @@ -1750,9 +1802,12 @@ dependencies = [ "flate2", "log", "once_cell", + "rustls", + "rustls-webpki", "serde", "serde_json", "url", + "webpki-roots", ] [[package]] @@ -1912,6 +1967,12 @@ version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "which" version = "4.4.2" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index ef0df3b..fcbe28b 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "2.0.0-alpha3" +version = "2.0.0-alpha4" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" @@ -43,7 +43,7 @@ chrono = { version = "0.4", features = [ "serde" ] } libryzenadj = { version = "0.13" } # ureq's tls feature does not like musl targets -ureq = { version = "2", features = ["json", "gzip", "brotli", "charset"], default-features = false, optional = true } +ureq = { version = "2", features = ["json", "gzip", "brotli", "charset", "tls"], default-features = false, optional = true } clap = { version = "4.4", features = [ "derive" ] } diff --git a/backend/src/api/web.rs b/backend/src/api/web.rs index c5f2d2f..b395e85 100644 --- a/backend/src/api/web.rs +++ b/backend/src/api/web.rs @@ -91,7 +91,7 @@ fn save_cache(cache: &StoreCache) { fn get_maybe_cached(steam_app_id: u32) -> Vec { let mut cache = load_cache(); - if let Some(cached_result) = cache.get(&steam_app_id) { + let data = if let Some(cached_result) = cache.get(&steam_app_id) { if cached_result.updated < (Utc::now() - MAX_CACHE_DURATION) { // cache needs update if let Ok(result) = search_by_app_id_online(steam_app_id) { @@ -126,6 +126,14 @@ fn get_maybe_cached(steam_app_id: u32) -> Vec = ({}) => { backend.resolve( backend.loadGeneralSettingsVariant("please give me a new ID k thx bye" /* anything that cannot be parsed as a u64 will be set to u64::MAX, which will cause the back-end to auto-generate an ID */, name), (ok: boolean) => { - isVariantLoading = false; backend.log(backend.LogLevel.Debug, "New settings variant ok? " + ok); reload(); backend.resolve(backend.waitForComplete(), (_) => { @@ -539,7 +538,7 @@ export default definePlugin((serverApi: ServerAPI) => { ico = ; } //registerCallbacks(false); - serverApi.routerHook.addRoute(STORE_RESULTS_URI, StoreResultsPage); + serverApi.routerHook.addRoute(STORE_RESULTS_URI, () => ); return { title:
PowerTools
, content: , @@ -548,7 +547,7 @@ export default definePlugin((serverApi: ServerAPI) => { tryNotifyProfileChange = function() {}; backend.log(backend.LogLevel.Debug, "PowerTools shutting down"); clearHooks(); - //serverApi.routerHook.removeRoute("/decky-plugin-test"); + serverApi.routerHook.removeRoute(STORE_RESULTS_URI); }, }; }); diff --git a/src/store/page.tsx b/src/store/page.tsx index a3269e1..da8f36d 100644 --- a/src/store/page.tsx +++ b/src/store/page.tsx @@ -1,19 +1,20 @@ import { Component } from "react"; import { HiDownload } from "react-icons/hi"; -import { PanelSectionRow, PanelSection, Focusable, staticClasses, DialogButton } from "decky-frontend-lib"; +import { PanelSectionRow, Focusable, staticClasses, DialogButton } from "decky-frontend-lib"; import * as backend from "../backend"; import { tr } from "usdpl-front"; -import { get_value} from "usdpl-front"; +import { get_value, set_value } from "usdpl-front"; import { STORE_RESULTS, + VARIANTS_GEN, } from "../consts"; -export class StoreResultsPage extends Component { - constructor() { - super({}); +export class StoreResultsPage extends Component<{onNewVariant: () => void}> { + constructor(props: {onNewVariant: () => void}) { + super(props); this.state = { reloadThingy: "/shrug", }; @@ -25,49 +26,60 @@ export class StoreResultsPage extends Component { if (storeItems) { if (storeItems.length == 0) { backend.log(backend.LogLevel.Warn, "No store results; got array with length 0 from cache"); - return ( + return ( { tr("No results") /* TODO translate */ } - ); + ); } else { // TODO - return ( + return ( { - storeItems.map((meta: backend.StoreMetadata) => { - + storeItems.map((meta: backend.StoreMetadata) => ( - { - backend.log(backend.LogLevel.Info, "Downloading settings " + meta.name + " (" + meta.id + ")"); - backend.storeDownloadById(meta.id); - }} - > - { /* TODO make this responsive when clicked */} - -
{ meta.name } @@ -76,33 +88,86 @@ export class StoreResultsPage extends Component { display: "flex", flexDirection: "row", minWidth: "0", - fontSize: "12px", + fontSize: "20px", + padding: "0.25em", }} className={staticClasses.Text}> { tr("Created by") /* TODO translate */} { meta.steam_username }
-
+
{ meta.tags.map((tag: string) => ( {tag} ) ) }
+ { + backend.log(backend.LogLevel.Info, "Downloading settings " + meta.name + " (" + meta.id + ")"); + backend.resolve(backend.storeDownloadById(meta.id), + (variants: backend.VariantInfo[]) => { + set_value(VARIANTS_GEN, variants) + this.props.onNewVariant(); + } + ); + }} + > + { /* TODO make this responsive when clicked */} + + - - }) + )) } - ); + ); } } else { backend.log(backend.LogLevel.Warn, "Store failed to load; got null from cache"); // store did not pre-load when the game started - return ( + return ( { tr("Store failed to load") /* TODO translate */ } - ); + ); } } }