From c374212b13d37193e8049dfa66a17b56eddf428a Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Fri, 31 Mar 2023 17:25:29 -0400 Subject: [PATCH] Only convert game ID to number in a language that doesn't have horrible number types --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/api/general.rs | 6 +++--- backend/src/api/handler.rs | 2 +- package.json | 2 +- src/backend.ts | 2 +- src/index.tsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 5b97b48..a395872 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1095,7 +1095,7 @@ dependencies = [ [[package]] name = "powertools" -version = "1.3.0-beta2" +version = "1.3.0-beta3" dependencies = [ "async-trait", "libryzenadj", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 3deb00c..c4539a9 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "1.3.0-beta2" +version = "1.3.0-beta3" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/src/api/general.rs b/backend/src/api/general.rs index 911da1f..fd032d8 100644 --- a/backend/src/api/general.rs +++ b/backend/src/api/general.rs @@ -55,7 +55,7 @@ pub fn load_settings( sender: Sender, ) -> impl Fn(super::ApiParameterType) -> super::ApiParameterType { let sender = Mutex::new(sender); // Sender is not Sync; this is required for safety - let setter = move |path: i64, name: String| { + let setter = move |path: u64, name: String| { sender .lock() .unwrap() @@ -63,9 +63,9 @@ pub fn load_settings( .expect("load_settings send failed") }; move |params_in: super::ApiParameterType| { - if let Some(Primitive::F64(id)) = params_in.get(0) { + if let Some(Primitive::String(id)) = params_in.get(0) { if let Some(Primitive::String(name)) = params_in.get(1) { - setter(*id as i64, name.to_owned()); + setter(id.parse().unwrap_or_default(), name.to_owned()); vec![true.into()] } else { log::warn!("load_settings missing name parameter"); diff --git a/backend/src/api/handler.rs b/backend/src/api/handler.rs index 62cb428..0b947ad 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -23,7 +23,7 @@ pub enum ApiMessage { OnChargeChange(f64), // battery fill amount: 0 = empty, 1 = full PowerVibeCheck, WaitForEmptyQueue(Callback<()>), - LoadSettings(i64, String), // (path, name) + LoadSettings(u64, String), // (path, name) LoadMainSettings, LoadSystemSettings, GetLimits(Callback), diff --git a/package.json b/package.json index 99e2922..41d6931 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.3.0-beta2", + "version": "1.3.0-beta3", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/backend.ts b/src/backend.ts index 5712428..8bc6761 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -243,7 +243,7 @@ export async function getGeneralPersistent(): Promise { return (await call_backend("GENERAL_get_persistent", []))[0]; } -export async function loadGeneralSettings(id: number, name: string): Promise { +export async function loadGeneralSettings(id: string, name: string): Promise { return (await call_backend("GENERAL_load_settings", [id, name]))[0]; } diff --git a/src/index.tsx b/src/index.tsx index 8fc7e9d..5a7daaa 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -180,7 +180,7 @@ const reload = function() { backend.log(backend.LogLevel.Info, "RegisterForGameActionStart callback(" + actionType + ", " + id + ")"); // don't use gameInfo.appid, haha backend.resolve( - backend.loadGeneralSettings(Number(id), gameInfo.display_name), + backend.loadGeneralSettings(id.toString(), gameInfo.display_name), (ok: boolean) => {backend.log(backend.LogLevel.Debug, "Loading settings ok? " + ok)} ); });