Fix store display
This commit is contained in:
parent
af8e8f5258
commit
a5e4ce29a6
6 changed files with 177 additions and 44 deletions
63
backend/Cargo.lock
generated
63
backend/Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "powertools"
|
||||
version = "2.0.0-alpha3"
|
||||
version = "2.0.0-alpha4"
|
||||
edition = "2021"
|
||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||
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" ] }
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ fn save_cache(cache: &StoreCache) {
|
|||
|
||||
fn get_maybe_cached(steam_app_id: u32) -> Vec<community_settings_core::v1::Metadata> {
|
||||
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<community_settings_core::v1::Metad
|
|||
} else {
|
||||
Vec::with_capacity(0)
|
||||
}
|
||||
};
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
data
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
data.into_iter().filter(|meta| meta.id != "0").collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "PowerTools",
|
||||
"version": "2.0.0-alpha3",
|
||||
"version": "2.0.0-alpha4",
|
||||
"description": "Power tweaks for power users",
|
||||
"scripts": {
|
||||
"build": "shx rm -rf dist && rollup -c",
|
||||
|
|
|
@ -355,7 +355,6 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({}) => {
|
|||
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 = <span><GiFireExtinguisher /><GiFireBomb /><GiMineExplosion /></span>;
|
||||
}
|
||||
//registerCallbacks(false);
|
||||
serverApi.routerHook.addRoute(STORE_RESULTS_URI, StoreResultsPage);
|
||||
serverApi.routerHook.addRoute(STORE_RESULTS_URI, () => <StoreResultsPage onNewVariant={tryNotifyProfileChange}/>);
|
||||
return {
|
||||
title: <div className={staticClasses.Title}>PowerTools</div>,
|
||||
content: <Content serverAPI={serverApi} />,
|
||||
|
@ -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);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
@ -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 (<PanelSection>
|
||||
return (<Focusable
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "center",
|
||||
rowGap: "5px",
|
||||
columnGap: "5px",
|
||||
maxWidth: "100%",
|
||||
margin: "auto",
|
||||
}}
|
||||
>
|
||||
{ tr("No results") /* TODO translate */ }
|
||||
</PanelSection>);
|
||||
</Focusable>);
|
||||
} else {
|
||||
// TODO
|
||||
return (<PanelSection>
|
||||
return (<Focusable
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "center",
|
||||
rowGap: "5px",
|
||||
columnGap: "5px",
|
||||
maxWidth: "100%",
|
||||
margin: "2em 0.5em",
|
||||
}}
|
||||
>
|
||||
{
|
||||
storeItems.map((meta: backend.StoreMetadata) => {
|
||||
<PanelSectionRow>
|
||||
storeItems.map((meta: backend.StoreMetadata) => (<PanelSectionRow>
|
||||
<Focusable style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
borderRadius: "2px",
|
||||
borderRadius: "1em",
|
||||
maxWidth: "100%",
|
||||
padding: "1em",
|
||||
//borderColor: "#93b3c8", // light blue bg colour
|
||||
//borderWidth: "0.1em",
|
||||
//borderStyle: "solid",
|
||||
margin: "0.5em",
|
||||
}}>
|
||||
<DialogButton
|
||||
//layout="below"
|
||||
style={{
|
||||
width: "56px",
|
||||
display: "flex",
|
||||
flexShrink: "0",
|
||||
alignSelf: "center",
|
||||
}}
|
||||
onClick={(_: MouseEvent) => {
|
||||
backend.log(backend.LogLevel.Info, "Downloading settings " + meta.name + " (" + meta.id + ")");
|
||||
backend.storeDownloadById(meta.id);
|
||||
}}
|
||||
>
|
||||
{ /* TODO make this responsive when clicked */}
|
||||
<HiDownload/>
|
||||
</DialogButton>
|
||||
<div style={{
|
||||
flexGrow: "1",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
minWidth: "0",
|
||||
marginBottom: "2px",
|
||||
padding: "0.25em",
|
||||
}}
|
||||
className={staticClasses.Text}>
|
||||
<div style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
minWidth: "0",
|
||||
fontSize: "16px",
|
||||
fontSize: "24px",
|
||||
padding: "0.25em",
|
||||
}}
|
||||
className={staticClasses.Text}>
|
||||
{ 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 }
|
||||
</div>
|
||||
<div>
|
||||
<div style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
minWidth: "0",
|
||||
fontSize: "16px",
|
||||
padding: "0.25em",
|
||||
}}>
|
||||
{ meta.tags.map((tag: string) => (<span style={{
|
||||
borderRadius: "10px",
|
||||
borderRadius: "1em",
|
||||
borderColor: "#dbe2e6", // main text colour
|
||||
backgroundColor: "#dbe2e6",
|
||||
color: "#1f2126", // main top image bg colour
|
||||
padding: "0.25em",
|
||||
margin: "0.25em",
|
||||
display: "flex",
|
||||
minWidth: "0",
|
||||
justifyContent: "center",
|
||||
fontSize: "12px",
|
||||
flexGrow: "1",
|
||||
}}>
|
||||
{tag}
|
||||
</span>)
|
||||
) }
|
||||
</div>
|
||||
</div>
|
||||
</Focusable>
|
||||
</PanelSectionRow>
|
||||
})
|
||||
<DialogButton
|
||||
//layout="below"
|
||||
style={{
|
||||
minWidth: "56px",
|
||||
maxWidth: "56px",
|
||||
display: "flex",
|
||||
flexShrink: "0",
|
||||
alignSelf: "center",
|
||||
padding: "1em",
|
||||
margin: "0.5em",
|
||||
}}
|
||||
onClick={(_: MouseEvent) => {
|
||||
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();
|
||||
}
|
||||
</PanelSection>);
|
||||
);
|
||||
}}
|
||||
>
|
||||
{ /* TODO make this responsive when clicked */}
|
||||
<HiDownload style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
}}/>
|
||||
</DialogButton>
|
||||
</Focusable>
|
||||
</PanelSectionRow>))
|
||||
}
|
||||
</Focusable>);
|
||||
}
|
||||
|
||||
} else {
|
||||
backend.log(backend.LogLevel.Warn, "Store failed to load; got null from cache");
|
||||
// store did not pre-load when the game started
|
||||
return (<PanelSection>
|
||||
return (<Focusable
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "center",
|
||||
rowGap: "5px",
|
||||
columnGap: "5px",
|
||||
maxWidth: "100%",
|
||||
margin: "auto",
|
||||
}}
|
||||
>
|
||||
{ tr("Store failed to load") /* TODO translate */ }
|
||||
</PanelSection>);
|
||||
</Focusable>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue