Only convert game ID to number in a language that doesn't have horrible number types

This commit is contained in:
NGnius (Graham) 2023-03-31 17:25:29 -04:00
parent 1d57edfd80
commit c374212b13
7 changed files with 9 additions and 9 deletions

2
backend/Cargo.lock generated
View file

@ -1095,7 +1095,7 @@ dependencies = [
[[package]]
name = "powertools"
version = "1.3.0-beta2"
version = "1.3.0-beta3"
dependencies = [
"async-trait",
"libryzenadj",

View file

@ -1,6 +1,6 @@
[package]
name = "powertools"
version = "1.3.0-beta2"
version = "1.3.0-beta3"
edition = "2021"
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
description = "Backend (superuser) functionality for PowerTools"

View file

@ -55,7 +55,7 @@ pub fn load_settings(
sender: Sender<ApiMessage>,
) -> 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");

View file

@ -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<super::SettingsLimits>),

View file

@ -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",

View file

@ -243,7 +243,7 @@ export async function getGeneralPersistent(): Promise<boolean> {
return (await call_backend("GENERAL_get_persistent", []))[0];
}
export async function loadGeneralSettings(id: number, name: string): Promise<boolean> {
export async function loadGeneralSettings(id: string, name: string): Promise<boolean> {
return (await call_backend("GENERAL_load_settings", [id, name]))[0];
}

View file

@ -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)}
);
});