mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-07-25 01:13:57 +10:00
feat(settings): Allow settings to update UI using fetch_settings command
This commit is contained in:
@@ -210,6 +210,7 @@ import {
|
|||||||
} from "@headlessui/vue";
|
} from "@headlessui/vue";
|
||||||
import { FolderIcon, TrashIcon, XCircleIcon } from "@heroicons/vue/16/solid";
|
import { FolderIcon, TrashIcon, XCircleIcon } from "@heroicons/vue/16/solid";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { type Settings } from "~/types";
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const currentDirectory = ref<string | undefined>(undefined);
|
const currentDirectory = ref<string | undefined>(undefined);
|
||||||
@@ -218,8 +219,7 @@ const createDirectoryLoading = ref(false);
|
|||||||
|
|
||||||
const dirs = ref<Array<string>>([]);
|
const dirs = ref<Array<string>>([]);
|
||||||
|
|
||||||
const downloadThreads = ref(4);
|
const downloadThreads = ref(((await invoke("fetch_settings")) as Settings).maxDownloadThreads ?? 0);
|
||||||
const downloadThreadsChanged = computed(() => downloadThreads.value !== 4);
|
|
||||||
|
|
||||||
async function updateDirs() {
|
async function updateDirs() {
|
||||||
const newDirs = await invoke<Array<string>>("fetch_download_dir_stats");
|
const newDirs = await invoke<Array<string>>("fetch_download_dir_stats");
|
||||||
|
|||||||
@@ -68,7 +68,10 @@ pub fn update_settings(new_settings: Value) {
|
|||||||
db_lock.settings = new_settings;
|
db_lock.settings = new_settings;
|
||||||
println!("New Settings: {:?}", db_lock.settings);
|
println!("New Settings: {:?}", db_lock.settings);
|
||||||
}
|
}
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn fetch_settings() -> Settings {
|
||||||
|
DB.borrow_data().unwrap().settings.clone()
|
||||||
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_system_data() -> SystemData {
|
pub fn fetch_system_data() -> SystemData {
|
||||||
let db_handle = DB.borrow_data().unwrap();
|
let db_handle = DB.borrow_data().unwrap();
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ use autostart::{get_autostart_enabled, toggle_autostart};
|
|||||||
use cleanup::{cleanup_and_exit, quit};
|
use cleanup::{cleanup_and_exit, quit};
|
||||||
use commands::fetch_state;
|
use commands::fetch_state;
|
||||||
use database::commands::{
|
use database::commands::{
|
||||||
add_download_dir, delete_download_dir, fetch_download_dir_stats, fetch_system_data,
|
add_download_dir, delete_download_dir, fetch_download_dir_stats, fetch_system_data, fetch_settings, update_settings
|
||||||
update_settings,
|
|
||||||
};
|
};
|
||||||
use database::db::{DatabaseInterface, GameDownloadStatus, DATA_ROOT_DIR};
|
use database::db::{DatabaseInterface, GameDownloadStatus, DATA_ROOT_DIR};
|
||||||
use download_manager::commands::{
|
use download_manager::commands::{
|
||||||
@@ -221,6 +220,7 @@ pub fn run() {
|
|||||||
fetch_system_data,
|
fetch_system_data,
|
||||||
// User utils
|
// User utils
|
||||||
update_settings,
|
update_settings,
|
||||||
|
fetch_settings,
|
||||||
// Auth
|
// Auth
|
||||||
auth_initiate,
|
auth_initiate,
|
||||||
retry_connect,
|
retry_connect,
|
||||||
|
|||||||
Reference in New Issue
Block a user