Add api to get a list of all tags

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 7e8b244018
commit a0316b01d2

@ -27,6 +27,12 @@ impl TagApi {
Self { ctx } Self { ctx }
} }
/// Returns a list of all tags stored in the repo
#[tracing::instrument(level = "debug", skip(self))]
pub async fn get_all_tags(&self) -> ApiResult<Vec<String>> {
self.emit_and_get("all_tags", ()).await
}
/// Returns a list of all tags for a file /// Returns a list of all tags for a file
#[tracing::instrument(level = "debug", skip(self))] #[tracing::instrument(level = "debug", skip(self))]
pub async fn get_tags_for_file(&self, hash: String) -> ApiResult<Vec<TagResponse>> { pub async fn get_tags_for_file(&self, hash: String) -> ApiResult<Vec<TagResponse>> {

@ -2,6 +2,14 @@ use crate::tauri_plugin::commands::ApiAccess;
use crate::tauri_plugin::error::PluginResult; use crate::tauri_plugin::error::PluginResult;
use crate::types::tags::TagResponse; use crate::types::tags::TagResponse;
#[tauri::command]
pub async fn get_all_tags(api_state: ApiAccess<'_>) -> PluginResult<Vec<String>> {
let api = api_state.api().await?;
let all_tags = api.tag.get_all_tags().await?;
Ok(all_tags)
}
#[tauri::command] #[tauri::command]
pub async fn get_tags_for_file( pub async fn get_tags_for_file(
hash: String, hash: String,

@ -33,6 +33,7 @@ impl<R: Runtime> MediarepoPlugin<R> {
get_file_thumbnails, get_file_thumbnails,
read_thumbnail, read_thumbnail,
get_repositories, get_repositories,
get_all_tags,
get_tags_for_file, get_tags_for_file,
get_active_repository, get_active_repository,
add_repository, add_repository,

Loading…
Cancel
Save