refactor(v2): migrate remaining unknown frontend invokes to v2 commands
cx
This commit is contained in:
1 parent
d02b8a9628
commit
0aecda77e5
8 files changed
+124
-15
No files matched your search
@@ -4949,3 +4949,99 @@ pub async fn v2_factory_reset(
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_qobuz_tos_accepted(
|
||||||
|
state: State<'_, crate::config::legal_settings::LegalSettingsState>,
|
||||||
|
accepted: bool,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::config::legal_settings::set_qobuz_tos_accepted(state, accepted)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_update_check_on_launch(
|
||||||
|
enabled: bool,
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::set_update_check_on_launch(enabled, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_show_whats_new_on_launch(
|
||||||
|
enabled: bool,
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::set_show_whats_new_on_launch(enabled, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_acknowledge_release(
|
||||||
|
version: String,
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::acknowledge_release(version, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_ignore_release(
|
||||||
|
version: String,
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::ignore_release(version, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_mark_whats_new_shown(
|
||||||
|
version: String,
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::mark_whats_new_shown(version, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_mark_flatpak_welcome_shown(
|
||||||
|
state: State<'_, crate::updates::UpdatesState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::updates::mark_flatpak_welcome_shown(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_get_backend_logs() -> Vec<String> {
|
||||||
|
crate::logging::get_backend_logs()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn v2_upload_logs_to_paste(content: String) -> Result<String, String> {
|
||||||
|
crate::logging::upload_logs_to_paste(content).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_show_downloads_in_library(
|
||||||
|
show: bool,
|
||||||
|
state: State<'_, crate::config::download_settings::DownloadSettingsState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::config::download_settings::set_show_downloads_in_library(show, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_device_sample_rate_limit(
|
||||||
|
state: State<'_, crate::config::audio_settings::AudioSettingsState>,
|
||||||
|
device_id: String,
|
||||||
|
rate: Option<u32>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::config::audio_settings::set_device_sample_rate_limit(state, device_id, rate)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_set_force_x11(
|
||||||
|
state: State<'_, crate::config::graphics_settings::GraphicsSettingsState>,
|
||||||
|
enabled: bool,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
crate::config::graphics_settings::set_force_x11(state, enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn v2_restart_app(app: tauri::AppHandle) {
|
||||||
|
log::info!("[V2] App restart requested by user");
|
||||||
|
app.restart();
|
||||||
|
}
|
||||||
@@ -1241,6 +1241,19 @@ pub fn run() {
|
|||||||
commands_v2::v2_library_write_album_metadata_to_files,
|
commands_v2::v2_library_write_album_metadata_to_files,
|
||||||
commands_v2::v2_library_refresh_album_metadata_from_files,
|
commands_v2::v2_library_refresh_album_metadata_from_files,
|
||||||
commands_v2::v2_factory_reset,
|
commands_v2::v2_factory_reset,
|
||||||
|
commands_v2::v2_set_qobuz_tos_accepted,
|
||||||
|
commands_v2::v2_set_update_check_on_launch,
|
||||||
|
commands_v2::v2_set_show_whats_new_on_launch,
|
||||||
|
commands_v2::v2_acknowledge_release,
|
||||||
|
commands_v2::v2_ignore_release,
|
||||||
|
commands_v2::v2_mark_whats_new_shown,
|
||||||
|
commands_v2::v2_mark_flatpak_welcome_shown,
|
||||||
|
commands_v2::v2_get_backend_logs,
|
||||||
|
commands_v2::v2_upload_logs_to_paste,
|
||||||
|
commands_v2::v2_set_show_downloads_in_library,
|
||||||
|
commands_v2::v2_set_device_sample_rate_limit,
|
||||||
|
commands_v2::v2_set_force_x11,
|
||||||
|
commands_v2::v2_restart_app,
|
||||||
// Queue (V2)
|
// Queue (V2)
|
||||||
commands_v2::v2_get_queue_state,
|
commands_v2::v2_get_queue_state,
|
||||||
commands_v2::v2_set_repeat_mode,
|
commands_v2::v2_set_repeat_mode,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
terminalUrl = '';
|
terminalUrl = '';
|
||||||
consoleUrl = '';
|
consoleUrl = '';
|
||||||
try {
|
try {
|
||||||
const lines: string[] = await invoke('get_backend_logs');
|
const lines: string[] = await invoke('v2_get_backend_logs');
|
||||||
terminalLogs = lines.join('\n');
|
terminalLogs = lines.join('\n');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
terminalLogs = `Error loading logs: ${e}`;
|
terminalLogs = `Error loading logs: ${e}`;
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
else isUploadingConsole = true;
|
else isUploadingConsole = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const url: string = await invoke('upload_logs_to_paste', { content });
|
const url: string = await invoke('v2_upload_logs_to_paste', { content });
|
||||||
if (tab === 'terminal') terminalUrl = url;
|
if (tab === 'terminal') terminalUrl = url;
|
||||||
else consoleUrl = url;
|
else consoleUrl = url;
|
||||||
await copyToClipboard(url);
|
await copyToClipboard(url);
|
||||||
|
|||||||
@@ -1797,7 +1797,7 @@
|
|||||||
|
|
||||||
async function handleShowDownloadsChange(enabled: boolean) {
|
async function handleShowDownloadsChange(enabled: boolean) {
|
||||||
try {
|
try {
|
||||||
await invoke('set_show_downloads_in_library', { show: enabled });
|
await invoke('v2_set_show_downloads_in_library', { show: enabled });
|
||||||
showQobuzDownloadsInLibrary = enabled;
|
showQobuzDownloadsInLibrary = enabled;
|
||||||
// Notify LocalLibraryView to refresh
|
// Notify LocalLibraryView to refresh
|
||||||
notifyDownloadSettingsChanged();
|
notifyDownloadSettingsChanged();
|
||||||
@@ -2369,7 +2369,7 @@
|
|||||||
const deviceId = outputDevice === 'System Default' ? 'default' : device?.id ?? 'default';
|
const deviceId = outputDevice === 'System Default' ? 'default' : device?.id ?? 'default';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('set_device_sample_rate_limit', { deviceId, rate });
|
await invoke('v2_set_device_sample_rate_limit', { deviceId, rate });
|
||||||
console.log('[Audio] Device max sample rate changed:', deviceId, rate);
|
console.log('[Audio] Device max sample rate changed:', deviceId, rate);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Audio] Failed to change device max sample rate:', err);
|
console.error('[Audio] Failed to change device max sample rate:', err);
|
||||||
@@ -2814,7 +2814,7 @@
|
|||||||
|
|
||||||
async function handleForceX11Change(enabled: boolean) {
|
async function handleForceX11Change(enabled: boolean) {
|
||||||
try {
|
try {
|
||||||
await invoke('set_force_x11', { enabled });
|
await invoke('v2_set_force_x11', { enabled });
|
||||||
forceX11 = enabled;
|
forceX11 = enabled;
|
||||||
showToast($t('settings.developer.restartRequired'), 'info');
|
showToast($t('settings.developer.restartRequired'), 'info');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ async function shouldShowFlatpakWelcome(): Promise<boolean> {
|
|||||||
*/
|
*/
|
||||||
export async function markFlatpakWelcomeShown(): Promise<void> {
|
export async function markFlatpakWelcomeShown(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await invoke('mark_flatpak_welcome_shown');
|
await invoke('v2_mark_flatpak_welcome_shown');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.debug('[Updates] Failed to mark flatpak welcome shown:', error);
|
console.debug('[Updates] Failed to mark flatpak welcome shown:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export async function loadTosAcceptance(): Promise<boolean> {
|
|||||||
if (localValue) {
|
if (localValue) {
|
||||||
// Migrate to Rust storage
|
// Migrate to Rust storage
|
||||||
try {
|
try {
|
||||||
await invoke('set_qobuz_tos_accepted', { accepted: true });
|
await invoke('v2_set_qobuz_tos_accepted', { accepted: true });
|
||||||
qobuzTosAccepted.set(true);
|
qobuzTosAccepted.set(true);
|
||||||
localStorage.removeItem('qbz-qobuz-tos-accepted');
|
localStorage.removeItem('qbz-qobuz-tos-accepted');
|
||||||
console.log('Migrated ToS acceptance to Rust storage');
|
console.log('Migrated ToS acceptance to Rust storage');
|
||||||
@@ -48,7 +48,7 @@ export async function setTosAcceptance(accepted: boolean): Promise<void> {
|
|||||||
if (!browser) return;
|
if (!browser) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('set_qobuz_tos_accepted', { accepted });
|
await invoke('v2_set_qobuz_tos_accepted', { accepted });
|
||||||
qobuzTosAccepted.set(accepted);
|
qobuzTosAccepted.set(accepted);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to save ToS acceptance:', err);
|
console.error('Failed to save ToS acceptance:', err);
|
||||||
@@ -72,7 +72,7 @@ if (browser) {
|
|||||||
lastValue = value;
|
lastValue = value;
|
||||||
|
|
||||||
// Persist to Rust (fire and forget, errors logged in setTosAcceptance)
|
// Persist to Rust (fire and forget, errors logged in setTosAcceptance)
|
||||||
invoke('set_qobuz_tos_accepted', { accepted: value }).catch((err) => {
|
invoke('v2_set_qobuz_tos_accepted', { accepted: value }).catch((err) => {
|
||||||
console.debug('Failed to persist ToS acceptance:', err);
|
console.debug('Failed to persist ToS acceptance:', err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export async function setUseSystemTitleBar(value: boolean): Promise<void> {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await invoke('v2_set_use_system_titlebar', { value });
|
await invoke('v2_set_use_system_titlebar', { value });
|
||||||
await invoke('restart_app');
|
await invoke('v2_restart_app');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[TitleBarStore] Failed to apply system titlebar change:', e);
|
console.error('[TitleBarStore] Failed to apply system titlebar change:', e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export async function refreshUpdatePreferences(): Promise<void> {
|
|||||||
|
|
||||||
export async function setCheckOnLaunch(enabled: boolean): Promise<void> {
|
export async function setCheckOnLaunch(enabled: boolean): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await invoke('set_update_check_on_launch', { enabled });
|
await invoke('v2_set_update_check_on_launch', { enabled });
|
||||||
preferences.checkOnLaunch = enabled;
|
preferences.checkOnLaunch = enabled;
|
||||||
notify();
|
notify();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -111,7 +111,7 @@ export async function setCheckOnLaunch(enabled: boolean): Promise<void> {
|
|||||||
|
|
||||||
export async function setShowWhatsNewOnLaunch(enabled: boolean): Promise<void> {
|
export async function setShowWhatsNewOnLaunch(enabled: boolean): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await invoke('set_show_whats_new_on_launch', { enabled });
|
await invoke('v2_set_show_whats_new_on_launch', { enabled });
|
||||||
preferences.showWhatsNewOnLaunch = enabled;
|
preferences.showWhatsNewOnLaunch = enabled;
|
||||||
notify();
|
notify();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -139,11 +139,11 @@ export async function fetchReleaseForVersion(version: string): Promise<ReleaseIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function acknowledgeRelease(version: string): Promise<void> {
|
export async function acknowledgeRelease(version: string): Promise<void> {
|
||||||
await invoke('acknowledge_release', { version });
|
await invoke('v2_acknowledge_release', { version });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ignoreRelease(version: string): Promise<void> {
|
export async function ignoreRelease(version: string): Promise<void> {
|
||||||
await invoke('ignore_release', { version });
|
await invoke('v2_ignore_release', { version });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function hasWhatsNewBeenShown(version: string): Promise<boolean> {
|
export async function hasWhatsNewBeenShown(version: string): Promise<boolean> {
|
||||||
@@ -157,7 +157,7 @@ export async function hasWhatsNewBeenShown(version: string): Promise<boolean> {
|
|||||||
|
|
||||||
export async function markWhatsNewShown(version: string): Promise<void> {
|
export async function markWhatsNewShown(version: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await invoke('mark_whats_new_shown', { version });
|
await invoke('v2_mark_whats_new_shown', { version });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.debug('[Updates] Failed to mark whats_new_shown:', version, error);
|
console.debug('[Updates] Failed to mark whats_new_shown:', version, error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user