set directory

This commit is contained in:
Brandon Thomas committed 2025-05-05 21:02:31 -04:00
1 parent 3537eb5b51
commit e54a1cd219
2 files changed
+14 -4

No files matched your search

@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { Button } from "@storyteller/ui-button";
import { Input } from "@storyteller/ui-input";
import { AppPreferencesPayload, GetAppPreferences, CustomDirectory } from "@storyteller/tauri-api";
import { AppPreferencesPayload, CustomDirectory, GetAppPreferences } from "@storyteller/tauri-api";
import { PreferenceName, UpdateAppPreferences } from "libs/tauri-api/src/lib/settings/UpdateAppPreference";
import { open } from '@tauri-apps/plugin-dialog';
@@ -57,9 +57,14 @@ export const MiscSettingsPane = (args: MiscSettingsPaneProps) => {
});
if (directory === null) {
return;
return; // User dismissed the dialog choice
}
// Serialize for backend
directory = JSON.stringify({
custom: directory,
} as CustomDirectory);
await UpdateAppPreferences({
preference: PreferenceName.PreferredDownloadDirectory,
value: directory,
@@ -6,14 +6,19 @@ export interface GetAppPreferencesResult {
export interface AppPreferencesPayload {
// Preferred download directory
preferred_download_directory: string | CustomDirectory,
preferred_download_directory: SystemDirectory | CustomDirectory,
// Play sounds on events.
play_sounds: boolean,
}
export interface SystemDirectory {
// If the directory is a system directory.
system: string,
}
export interface CustomDirectory {
// If the directory is custom.
// If the directory is a custom user directory.
custom: string,
}