Tag fetching and caching (#59)

* basic framework. still has errors

* added functionality for main endpoints + some structuring

* formatting

* unused code

* mimicked CLI function with wait_for process

* added basic auth bindings

* made PR changes, added playground

* cargo fmt

* removed missed println

* misc tests fixes

* cargo fmt

* added windows support

* cargo fmt

* all OS use dunce

* restructured profile slightly; fixed mac bug

* profile changes, new main.rs

* fixed requested pr + canonicaliation bug

* fixed regressed bug in ui

* fixed regressed bugs

* fixed git error

* typo

* ran prettier

* clippy

* playground clippy

* ported profile loading fix

* profile change for real, url println and clippy

* PR changes

* auth bindings + semisynch flow

* fixed dropping task error

* prettier, eslint, clippy

* removed debugging modifications

* removed unused function that eslinter missed :(

* initial errored push

* working draft

* added tag system!

* fixed merge issue

---------

Co-authored-by: Wyatt <wyatt@modrinth.com>
This commit is contained in:
Wyatt Verchere
2023-04-03 16:08:53 -07:00
committed by GitHub
parent a13b7a2566
commit b0c830119b
9 changed files with 436 additions and 2 deletions

View File

@@ -3,9 +3,9 @@ use serde::{Serialize, Serializer};
use thiserror::Error;
pub mod auth;
pub mod profile;
pub mod profile_create;
pub mod tags;
pub mod settings;
pub type Result<T> = std::result::Result<T, TheseusGuiError>;

View File

@@ -0,0 +1,47 @@
use crate::api::Result;
use theseus::tags::{
Category, DonationPlatform, GameVersion, License, Loader, TagBundle,
};
/// Gets cached category tags from the database
#[tauri::command]
pub async fn tags_get_category_tags() -> Result<Vec<Category>> {
Ok(theseus::tags::get_category_tags().await?)
}
/// Gets cached report type tags from the database
#[tauri::command]
pub async fn tags_get_report_type_tags() -> Result<Vec<String>> {
Ok(theseus::tags::get_report_type_tags().await?)
}
/// Gets cached loader tags from the database
#[tauri::command]
pub async fn tags_get_loader_tags() -> Result<Vec<Loader>> {
Ok(theseus::tags::get_loader_tags().await?)
}
/// Gets cached game version tags from the database
#[tauri::command]
pub async fn tags_get_game_version_tags() -> Result<Vec<GameVersion>> {
Ok(theseus::tags::get_game_version_tags().await?)
}
/// Gets cached license tags from the database
#[tauri::command]
pub async fn tags_get_license_tags() -> Result<Vec<License>> {
Ok(theseus::tags::get_license_tags().await?)
}
/// Gets cached donation platform tags from the database
#[tauri::command]
pub async fn tags_get_donation_platform_tags() -> Result<Vec<DonationPlatform>>
{
Ok(theseus::tags::get_donation_platform_tags().await?)
}
/// Gets cached tag bundle from the database
#[tauri::command]
pub async fn tags_get_tag_bundle() -> Result<TagBundle> {
Ok(theseus::tags::get_tag_bundle().await?)
}

View File

@@ -38,6 +38,13 @@ fn main() {
api::auth::auth_has_user,
api::auth::auth_users,
api::auth::auth_get_user,
api::tags::tags_get_category_tags,
api::tags::tags_get_donation_platform_tags,
api::tags::tags_get_game_version_tags,
api::tags::tags_get_loader_tags,
api::tags::tags_get_license_tags,
api::tags::tags_get_report_type_tags,
api::tags::tags_get_tag_bundle,
api::settings::settings_get,
api::settings::settings_set,
])

View File

@@ -0,0 +1,41 @@
/**
* All theseus API calls return serialized values (both return values and errors);
* So, for example, addDefaultInstance creates a blank Profile object, where the Rust struct is serialized,
* and deserialized into a usable JS object.
*/
import { invoke } from '@tauri-apps/api/tauri'
// Gets tag bundle of all tags
export async function get_tag_bundle() {
return await invoke('tags_get_tag_bundle')
}
// Gets cached category tags
export async function get_categories() {
return await invoke('tags_get_categories')
}
// Gets cached loaders tags
export async function get_loaders() {
return await invoke('tags_get_loaders')
}
// Gets cached game_versions tags
export async function get_game_versions() {
return await invoke('tags_get_game_versions')
}
// Gets cached licenses tags
export async function get_licenses() {
return await invoke('tags_get_licenses')
}
// Gets cached donation_platforms tags
export async function get_donation_platforms() {
return await invoke('tags_get_donation_platforms')
}
// Gets cached licenses tags
export async function get_report_types() {
return await invoke('tags_get_report_types')
}