mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-06-22 04:11:37 +10:00
More refactoring and renaming camelCase struct definitions to snake_case
This commit is contained in:
+7
-12
@@ -6,17 +6,15 @@ mod unpacker;
|
|||||||
|
|
||||||
use auth::{auth_initiate, generate_authorization_header, recieve_handshake};
|
use auth::{auth_initiate, generate_authorization_header, recieve_handshake};
|
||||||
use db::{fetch_base_url, DatabaseInterface, DATA_ROOT_DIR};
|
use db::{fetch_base_url, DatabaseInterface, DATA_ROOT_DIR};
|
||||||
use env_logger;
|
|
||||||
use env_logger::Env;
|
use env_logger::Env;
|
||||||
use http::{header::*, response::Builder as ResponseBuilder, status::StatusCode};
|
use http::{header::*, response::Builder as ResponseBuilder};
|
||||||
use library::{fetch_game, fetch_library, Game};
|
use library::{fetch_game, fetch_library, Game};
|
||||||
use log::info;
|
use log::info;
|
||||||
use remote::{gen_drop_url, use_remote};
|
use remote::{gen_drop_url, use_remote};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap, io, sync::{LazyLock, Mutex}, task, thread
|
collections::HashMap, sync::{LazyLock, Mutex}
|
||||||
};
|
};
|
||||||
use structured_logger::{json::new_writer, Builder};
|
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Serialize)]
|
#[derive(Clone, Copy, Serialize)]
|
||||||
@@ -63,14 +61,14 @@ fn setup<'a>() -> AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let auth_result = auth::setup().unwrap();
|
let auth_result = auth::setup().unwrap();
|
||||||
return AppState {
|
AppState {
|
||||||
status: auth_result.0,
|
status: auth_result.0,
|
||||||
user: auth_result.1,
|
user: auth_result.1,
|
||||||
games: HashMap::new(),
|
games: HashMap::new(),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(|| db::setup());
|
pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(db::setup);
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
@@ -128,11 +126,8 @@ pub fn run() {
|
|||||||
app.deep_link().on_open_url(move |event| {
|
app.deep_link().on_open_url(move |event| {
|
||||||
info!("handling drop:// url");
|
info!("handling drop:// url");
|
||||||
let binding = event.urls();
|
let binding = event.urls();
|
||||||
let url = binding.get(0).unwrap();
|
let url = binding.first().unwrap();
|
||||||
match url.host_str().unwrap() {
|
if url.host_str().unwrap() == "handshake" { recieve_handshake(handle.clone(), url.path().to_string()) }
|
||||||
"handshake" => recieve_handshake(handle.clone(), url.path().to_string()),
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+11
-10
@@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::BorrowMut, sync::Mutex};
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@@ -7,18 +7,19 @@ use tauri::{AppHandle, Manager};
|
|||||||
use crate::{auth::generate_authorization_header, db::fetch_base_url, AppState};
|
use crate::{auth::generate_authorization_header, db::fetch_base_url, AppState};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
id: String,
|
id: String,
|
||||||
mName: String,
|
m_name: String,
|
||||||
mShortDescription: String,
|
m_short_description: String,
|
||||||
mDescription: String,
|
m_description: String,
|
||||||
// mDevelopers
|
// mDevelopers
|
||||||
// mPublishers
|
// mPublishers
|
||||||
|
|
||||||
mIconId: String,
|
m_icon_id: String,
|
||||||
mBannerId: String,
|
m_banner_id: String,
|
||||||
mCoverId: String,
|
m_cover_id: String,
|
||||||
mImageLibrary: Vec<String>,
|
m_image_library: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -54,7 +55,7 @@ pub fn fetch_library(app: AppHandle) -> Result<String, String> {
|
|||||||
|
|
||||||
drop(handle);
|
drop(handle);
|
||||||
|
|
||||||
return Ok(json!(games.clone()).to_string());
|
Ok(json!(games.clone()).to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -66,5 +67,5 @@ pub fn fetch_game(id: String, app: tauri::AppHandle) -> Result<String, String> {
|
|||||||
return Ok(json!(game.unwrap()).to_string());
|
return Ok(json!(game.unwrap()).to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok("".to_string());
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user