mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
refactor(lib_commands): drop super::* + glob re-export in sync + lib.rs
Hotspot G next slice — replace cascade-imports in lib_commands/sync/
{device,batch,tray}.rs with explicit per-symbol imports + per-command
re-exports.
sync/mod.rs lists each Tauri command from device / batch / tray
explicitly, plus the three internal helpers consumed by lib.rs and
ui/mini.rs (is_tiling_wm, stop_audio_engine, try_build_tray_icon).
The previous broad `pub(crate) use device::*` etc. is gone.
Inside the .rs files: each `use super::*` is replaced with what the
file actually needs — `super::device::{TrackSyncInfo, ...}` for batch,
`crate::tray_runtime::{Tray*}` + `crate::audio` + `super::super::ui::
{PAUSE_RENDERING_JS, RESUME_RENDERING_JS}` for tray, etc.
Cleanup in lib.rs: drop the now-unused tauri menu/tray imports
(MenuBuilder/MenuItemBuilder/PredefinedMenuItem/TrayIcon*/MouseButton*)
— tray.rs owns those now. Drop `Ordering` (no longer used at lib.rs
scope). Drop `pub(crate) use file_transfer::*;` from
lib_commands/mod.rs (file_transfer is now imported by direct path
where needed: `super::super::file_transfer::*`).
This commit is contained in:
+2
-10
@@ -17,18 +17,10 @@ pub(crate) use tray_runtime::*;
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Arc, Mutex, OnceLock, RwLock};
|
use std::sync::{Arc, Mutex, OnceLock, RwLock};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
use tauri::{
|
use tauri::{Emitter, Manager};
|
||||||
menu::{MenuBuilder, MenuItemBuilder, PredefinedMenuItem},
|
|
||||||
tray::{MouseButton, TrayIcon, TrayIconBuilder, TrayIconEvent},
|
|
||||||
Emitter, Manager,
|
|
||||||
};
|
|
||||||
use lib_commands::*;
|
use lib_commands::*;
|
||||||
// MouseButtonState is only matched on non-Windows targets — on Windows the
|
|
||||||
// tray uses DoubleClick which doesn't carry a button_state.
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
use tauri::tray::MouseButtonState;
|
|
||||||
|
|
||||||
/// Tracks which user-configured shortcuts are currently registered (shortcut_str → action).
|
/// Tracks which user-configured shortcuts are currently registered (shortcut_str → action).
|
||||||
/// Prevents on_shortcut() accumulating duplicate handlers across JS reloads (HMR / StrictMode).
|
/// Prevents on_shortcut() accumulating duplicate handlers across JS reloads (HMR / StrictMode).
|
||||||
|
|||||||
@@ -8,6 +8,5 @@ mod ui;
|
|||||||
|
|
||||||
pub(crate) use app_api::*;
|
pub(crate) use app_api::*;
|
||||||
pub(crate) use cache::*;
|
pub(crate) use cache::*;
|
||||||
pub(crate) use file_transfer::*;
|
|
||||||
pub(crate) use sync::*;
|
pub(crate) use sync::*;
|
||||||
pub(crate) use ui::*;
|
pub(crate) use ui::*;
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
use super::*;
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use tauri::Emitter;
|
||||||
|
|
||||||
|
use crate::sync_cancel_flags;
|
||||||
|
|
||||||
|
use super::super::file_transfer::{finalize_streamed_download, subsonic_http_client};
|
||||||
|
use super::device::{
|
||||||
|
build_track_path, get_removable_drives, is_path_on_mounted_volume, SyncBatchResult,
|
||||||
|
TrackSyncInfo,
|
||||||
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub(crate) async fn list_device_dir_files(dir: String) -> Result<Vec<String>, String> {
|
pub(crate) async fn list_device_dir_files(dir: String) -> Result<Vec<String>, String> {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
use super::*;
|
use tauri::Emitter;
|
||||||
|
|
||||||
|
use super::super::file_transfer::{finalize_streamed_download, subsonic_http_client};
|
||||||
|
|
||||||
// ─── Device Sync ─────────────────────────────────────────────────────────────
|
// ─── Device Sync ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
use super::*;
|
|
||||||
|
|
||||||
mod device;
|
mod device;
|
||||||
mod batch;
|
mod batch;
|
||||||
mod tray;
|
mod tray;
|
||||||
|
|
||||||
pub(crate) use device::*;
|
// Tauri commands re-exported for the lib.rs invoke_handler:
|
||||||
pub(crate) use batch::*;
|
pub(crate) use device::{
|
||||||
pub(crate) use tray::*;
|
get_removable_drives, read_device_manifest, rename_device_files, sync_track_to_device,
|
||||||
|
write_device_manifest, write_playlist_m3u8, compute_sync_paths,
|
||||||
|
};
|
||||||
|
pub(crate) use batch::{
|
||||||
|
calculate_sync_payload, cancel_device_sync, delete_device_file, delete_device_files,
|
||||||
|
list_device_dir_files, sync_batch_to_device,
|
||||||
|
};
|
||||||
|
pub(crate) use tray::{
|
||||||
|
is_tiling_wm_cmd, no_compositing_mode, set_tray_menu_labels, set_tray_tooltip,
|
||||||
|
toggle_tray_icon,
|
||||||
|
};
|
||||||
|
// Internal helpers consumed elsewhere in the crate:
|
||||||
|
pub(crate) use tray::{is_tiling_wm, stop_audio_engine, try_build_tray_icon};
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
use super::*;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
|
use tauri::menu::{MenuBuilder, MenuItemBuilder, PredefinedMenuItem};
|
||||||
|
use tauri::tray::{MouseButton, TrayIcon, TrayIconBuilder, TrayIconEvent};
|
||||||
|
use tauri::{Emitter, Manager};
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
use tauri::tray::MouseButtonState;
|
||||||
|
|
||||||
|
use crate::audio;
|
||||||
|
use crate::tray_runtime::{
|
||||||
|
tray_state_icon, TrayMenuItems, TrayMenuItemsState, TrayMenuLabels, TrayMenuLabelsState,
|
||||||
|
TrayPlaybackState, TrayState, TrayTooltip,
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::super::ui::{PAUSE_RENDERING_JS, RESUME_RENDERING_JS};
|
||||||
|
|
||||||
pub(crate) fn build_tray_icon(app: &tauri::AppHandle) -> tauri::Result<TrayIcon> {
|
pub(crate) fn build_tray_icon(app: &tauri::AppHandle) -> tauri::Result<TrayIcon> {
|
||||||
let labels = app
|
let labels = app
|
||||||
|
|||||||
Reference in New Issue
Block a user