Use TagQuery instead of strings for tag searches

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent b7742a0fba
commit 2ad64f61da

@ -39,15 +39,7 @@ impl FileApi {
/// Searches for a file by a list of tags /// Searches for a file by a list of tags
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn find_files(&self, tags: Vec<String>) -> ApiResult<Vec<FileMetadataResponse>> { pub async fn find_files(&self, tags: Vec<TagQuery>) -> ApiResult<Vec<FileMetadataResponse>> {
let tags = tags
.into_iter()
.map(|tag| TagQuery {
name: tag,
negate: false,
})
.collect();
self.emit_and_get("find_files", FindFilesByTagsRequest { tags }) self.emit_and_get("find_files", FindFilesByTagsRequest { tags })
.await .await
} }

@ -1,6 +1,6 @@
use crate::tauri_plugin::commands::{add_once_buffer, ApiAccess, BufferAccess}; use crate::tauri_plugin::commands::{add_once_buffer, ApiAccess, BufferAccess};
use crate::tauri_plugin::error::PluginResult; use crate::tauri_plugin::error::PluginResult;
use crate::types::files::{FileMetadataResponse, ThumbnailMetadataResponse}; use crate::types::files::{FileMetadataResponse, TagQuery, ThumbnailMetadataResponse};
#[tauri::command] #[tauri::command]
pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult<Vec<FileMetadataResponse>> { pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult<Vec<FileMetadataResponse>> {
@ -12,7 +12,7 @@ pub async fn get_all_files(api_state: ApiAccess<'_>) -> PluginResult<Vec<FileMet
#[tauri::command] #[tauri::command]
pub async fn find_files( pub async fn find_files(
tags: Vec<String>, tags: Vec<TagQuery>,
api_state: ApiAccess<'_>, api_state: ApiAccess<'_>,
) -> PluginResult<Vec<FileMetadataResponse>> { ) -> PluginResult<Vec<FileMetadataResponse>> {
let api = api_state.api().await?; let api = api_state.api().await?;

Loading…
Cancel
Save