Adds a new apply_wallpaper command and its plumbing across desktop, mobile, and Android. A WorkManager-based rotation worker handles applying wallpapers in the background. Wallpaper state now tracks currentId and imageIds for precise control. - Introduced apply_wallpaper command across desktop, mobile and Android - Added WorkManager-based rotation worker to apply wallpapers in the background - Extended wallpaper state with currentId and imageIds and updated schemas/permissions
125 lines
3.5 KiB
Rust
125 lines
3.5 KiB
Rust
use tauri::{command, AppHandle, Runtime};
|
|
|
|
use crate::models::*;
|
|
use crate::Result;
|
|
use crate::WallpaperExt;
|
|
|
|
#[command]
|
|
pub(crate) async fn get_state<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
|
app.wallpaper().get_state()
|
|
}
|
|
#[command]
|
|
pub(crate) async fn get_gallery<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
offset: usize,
|
|
limit: usize,
|
|
) -> Result<GalleryPage> {
|
|
app.wallpaper()
|
|
.get_gallery(GalleryRequest { offset, limit })
|
|
}
|
|
#[command]
|
|
pub(crate) async fn select_images<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
|
app.wallpaper().select_images()
|
|
}
|
|
#[command]
|
|
pub(crate) async fn delete_image<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
id: String,
|
|
) -> Result<WallpaperState> {
|
|
app.wallpaper().delete_image(DeleteImageRequest { id })
|
|
}
|
|
#[command]
|
|
pub(crate) async fn get_image_ids<R: Runtime>(app: AppHandle<R>) -> Result<Vec<String>> {
|
|
app.wallpaper().get_image_ids()
|
|
}
|
|
#[command]
|
|
pub(crate) async fn delete_images<R: Runtime>(app: AppHandle<R>, ids: Vec<String>) -> Result<WallpaperState> {
|
|
app.wallpaper().delete_images(DeleteImagesRequest { ids })
|
|
}
|
|
#[command]
|
|
pub(crate) async fn set_image_crop<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
id: String,
|
|
mode: String,
|
|
zoom: f64,
|
|
position_x: f64,
|
|
position_y: f64,
|
|
rotation: i32,
|
|
) -> Result<GalleryImage> {
|
|
app.wallpaper().set_image_crop(ImageCropRequest {
|
|
id,
|
|
mode,
|
|
zoom,
|
|
position_x,
|
|
position_y,
|
|
rotation,
|
|
})
|
|
}
|
|
#[command]
|
|
pub(crate) async fn set_setting<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
name: String,
|
|
value: bool,
|
|
) -> Result<WallpaperState> {
|
|
app.wallpaper().set_setting(SettingRequest { name, value })
|
|
}
|
|
#[command]
|
|
pub(crate) async fn set_interval<R: Runtime>(app: AppHandle<R>, minutes: usize) -> Result<WallpaperState> {
|
|
app.wallpaper().set_interval(IntervalRequest { minutes })
|
|
}
|
|
#[command]
|
|
pub(crate) async fn next_wallpaper<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
|
app.wallpaper().next_wallpaper()
|
|
}
|
|
#[command]
|
|
pub(crate) async fn apply_wallpaper<R: Runtime>(app: AppHandle<R>, id: String) -> Result<WallpaperState> {
|
|
app.wallpaper().apply_wallpaper(ApplyWallpaperRequest { id })
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn get_immich_connection<R: Runtime>(app: AppHandle<R>) -> Result<ImmichConnection> {
|
|
app.wallpaper().get_immich_connection()
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn connect_immich<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
server_url: String,
|
|
api_key: String,
|
|
) -> Result<ImmichConnection> {
|
|
app.wallpaper().connect_immich(ImmichConnectRequest { server_url, api_key })
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn disconnect_immich<R: Runtime>(app: AppHandle<R>) -> Result<ImmichConnection> {
|
|
app.wallpaper().disconnect_immich()
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn get_immich_albums<R: Runtime>(app: AppHandle<R>) -> Result<ImmichAlbumsResponse> {
|
|
app.wallpaper().get_immich_albums()
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn get_immich_assets<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
album_id: Option<String>,
|
|
page: usize,
|
|
size: usize,
|
|
) -> Result<ImmichAssetsPage> {
|
|
app.wallpaper().get_immich_assets(ImmichAssetsRequest { album_id, page, size })
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn import_immich_assets<R: Runtime>(
|
|
app: AppHandle<R>,
|
|
ids: Vec<String>,
|
|
) -> Result<WallpaperState> {
|
|
app.wallpaper().import_immich_assets(ImmichImportRequest { ids })
|
|
}
|
|
|
|
#[command]
|
|
pub(crate) async fn get_immich_import_progress<R: Runtime>(app: AppHandle<R>) -> Result<ImmichImportProgress> {
|
|
app.wallpaper().get_immich_import_progress()
|
|
}
|