forked from didirus/AstralRinth
* Make theseus capable of logging messages from the `log` crate * Move update checking entirely into JS and open a modal if an update is available * Fix formatjs on Windows and run formatjs * Add in the buttons and body * Fix lint * Show update size in modal * Fix update not being rechecked if the update modal was directly dismissed * Slight UI tweaks * Fix lint * Implement skipping the update * Implement the Update Now button * Implement updating at next exit * Turn download progress into an error bar on failure * Restore 5 minute update check instead of 30 seconds * Fix PendingUpdateData being seen as a unit struct * Fix lint * Make CI also lint updater code * feat: create AppearingProgressBar component * feat: polish update available modal * feat: add error handling * Open changelog with tauri-plugin-opener * Run intl:extract * Update completion toasts (#3978) * Use single LAUNCHER_USER_AGENT constant for all user agents * Fix build on Mac * Request the update size with HEAD instead of GET * UI tweaks * lint * Fix lint * fix: hide modal header & add "Hide update reminder" button w/ tooltip * Run intl:extract * fix: lint issues * fix: merge issues * notifications.js no longer exists * Add metered network checking * Add a timeout to macOS is_network_metered * Fix tauri.conf.json * vibe debugging * Set a dispatch queue * Have a popup that asks you if you'd like to disable automatic file downloads if you're on a metered network * Move UpdateModal to modal package * Fix lint * Add a toggle for automatic downloads * Fix type Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com> Signed-off-by: Josiah Glosson <soujournme@gmail.com> * Redo updating UI and experience * lint * fix unlistener issue * remove unneeded translation keys * Fix expose issue * temp disable cranelift, tweak some messages * change version back * Clean up App.vue * move toast to top right * update reload icon * Fixed the bug!!!!!!!!!!!! * improve messages * intl:extract * Add liquid glass icon file * not you! * use dependency injection * lint on apple icon * Fix imports, move download size to button * change update check back to 5 mins * lint + move to providers * intl:extract --------- Signed-off-by: Cal H. <hendersoncal117@gmail.com> Signed-off-by: Josiah Glosson <soujournme@gmail.com> Co-authored-by: Calum <calum@modrinth.com> Co-authored-by: Prospector <prospectordev@gmail.com> Co-authored-by: Cal H. <hendersoncal117@gmail.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
116 lines
3.5 KiB
Rust
116 lines
3.5 KiB
Rust
use serde::ser::SerializeStruct;
|
|
use serde::{Serialize, Serializer};
|
|
use thiserror::Error;
|
|
|
|
pub mod auth;
|
|
pub mod import;
|
|
pub mod jre;
|
|
pub mod logs;
|
|
pub mod metadata;
|
|
pub mod minecraft_skins;
|
|
pub mod mr_auth;
|
|
pub mod pack;
|
|
pub mod process;
|
|
pub mod profile;
|
|
pub mod profile_create;
|
|
pub mod settings;
|
|
pub mod tags;
|
|
pub mod utils;
|
|
|
|
pub mod ads;
|
|
pub mod cache;
|
|
pub mod friends;
|
|
pub mod worlds;
|
|
|
|
mod oauth_utils;
|
|
|
|
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;
|
|
|
|
// // Main returnable Theseus GUI error
|
|
// // Needs to be Serializable to be returned to the JavaScript side
|
|
// #[derive(Error, Debug, Serialize)]
|
|
// pub enum TheseusGuiError {
|
|
// #[error(transparent)]
|
|
// Serializable(),
|
|
// }
|
|
|
|
// Serializable error intermediary, so TheseusGuiError can be Serializable (eg: so that we can return theseus::Errors in Tauri directly)
|
|
#[derive(Error, Debug)]
|
|
pub enum TheseusSerializableError {
|
|
#[error("{0}")]
|
|
Theseus(#[from] theseus::Error),
|
|
|
|
#[error("IO error: {0}")]
|
|
IO(#[from] std::io::Error),
|
|
|
|
#[error("Tauri error: {0}")]
|
|
Tauri(#[from] tauri::Error),
|
|
|
|
#[cfg(feature = "updater")]
|
|
#[error("Updater error: {0}")]
|
|
Updater(#[from] tauri_plugin_updater::Error),
|
|
|
|
#[cfg(feature = "updater")]
|
|
#[error("HTTP error: {0}")]
|
|
Http(#[from] tauri_plugin_http::reqwest::Error),
|
|
}
|
|
|
|
// Generic implementation of From<T> for ErrorTypeA
|
|
// impl<T> From<T> for TheseusGuiError
|
|
// where
|
|
// TheseusSerializableError: From<T>,
|
|
// {
|
|
// fn from(error: T) -> Self {
|
|
// TheseusGuiError::Serializable(TheseusSerializableError::from(error))
|
|
// }
|
|
// }
|
|
|
|
// This is a very simple macro that implements a very basic Serializable for each variant of TheseusSerializableError,
|
|
// where the field is the string. (This allows easy extension to errors without many match arms)
|
|
macro_rules! impl_serialize {
|
|
($($variant:ident),* $(,)?) => {
|
|
impl Serialize for TheseusSerializableError {
|
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
match self {
|
|
// For the Theseus variant, we add a special display for the error,
|
|
// to view the spans if subscribed to them (which is information that is lost when serializing)
|
|
TheseusSerializableError::Theseus(theseus_error) => {
|
|
$crate::error::display_tracing_error(theseus_error);
|
|
|
|
let mut state = serializer.serialize_struct("Theseus", 2)?;
|
|
state.serialize_field("field_name", "Theseus")?;
|
|
state.serialize_field("message", &theseus_error.to_string())?;
|
|
state.end()
|
|
}
|
|
$(
|
|
TheseusSerializableError::$variant(message) => {
|
|
let mut state = serializer.serialize_struct(stringify!($variant), 2)?;
|
|
state.serialize_field("field_name", stringify!($variant))?;
|
|
state.serialize_field("message", &message.to_string())?;
|
|
state.end()
|
|
},
|
|
)*
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// Use the macro to implement Serialize for TheseusSerializableError
|
|
#[cfg(not(feature = "updater"))]
|
|
impl_serialize! {
|
|
IO,
|
|
Tauri,
|
|
}
|
|
|
|
#[cfg(feature = "updater")]
|
|
impl_serialize! {
|
|
IO,
|
|
Tauri,
|
|
Updater,
|
|
Http,
|
|
}
|