From 2ad64f61daaa75975f1152369d57187e85894fdf Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 26 Oct 2021 21:58:08 +0200 Subject: [PATCH] Use TagQuery instead of strings for tag searches Signed-off-by: trivernis --- mediarepo-api/src/client_api/file.rs | 10 +--------- mediarepo-api/src/tauri_plugin/commands/file.rs | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/mediarepo-api/src/client_api/file.rs b/mediarepo-api/src/client_api/file.rs index 52033d3..5936527 100644 --- a/mediarepo-api/src/client_api/file.rs +++ b/mediarepo-api/src/client_api/file.rs @@ -39,15 +39,7 @@ impl FileApi { /// Searches for a file by a list of tags #[tracing::instrument(level = "debug", skip(self))] - pub async fn find_files(&self, tags: Vec) -> ApiResult> { - let tags = tags - .into_iter() - .map(|tag| TagQuery { - name: tag, - negate: false, - }) - .collect(); - + pub async fn find_files(&self, tags: Vec) -> ApiResult> { self.emit_and_get("find_files", FindFilesByTagsRequest { tags }) .await } diff --git a/mediarepo-api/src/tauri_plugin/commands/file.rs b/mediarepo-api/src/tauri_plugin/commands/file.rs index 535fc98..c7347e7 100644 --- a/mediarepo-api/src/tauri_plugin/commands/file.rs +++ b/mediarepo-api/src/tauri_plugin/commands/file.rs @@ -1,6 +1,6 @@ use crate::tauri_plugin::commands::{add_once_buffer, ApiAccess, BufferAccess}; use crate::tauri_plugin::error::PluginResult; -use crate::types::files::{FileMetadataResponse, ThumbnailMetadataResponse}; +use crate::types::files::{FileMetadataResponse, TagQuery, ThumbnailMetadataResponse}; #[tauri::command] pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult> { @@ -12,7 +12,7 @@ pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult, + tags: Vec, api_state: ApiAccess<'_>, ) -> PluginResult> { let api = api_state.api().await?;