From 10ac36c9899765d5af1d4dcea5eda94579b3c06d Mon Sep 17 00:00:00 2001 From: Marche Date: Thu, 27 Jul 2023 11:44:30 -0300 Subject: [PATCH 1/2] Handle Error (#149) --- crate/Cargo.lock | 2 +- crate/Cargo.toml | 2 +- ui/context/IDL/index.tsx | 6 ++++-- ui/src-tauri/Cargo.lock | 4 +++- ui/src-tauri/Cargo.toml | 2 +- ui/src-tauri/src/error.rs | 10 +++++++++- ui/src-tauri/src/new_window.rs | 3 ++- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/crate/Cargo.lock b/crate/Cargo.lock index 5dbca98..827221e 100644 --- a/crate/Cargo.lock +++ b/crate/Cargo.lock @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "soda_sol" -version = "0.0.6" +version = "0.0.7" dependencies = [ "bincode", "handlebars", diff --git a/crate/Cargo.toml b/crate/Cargo.toml index c3a636c..29ae052 100644 --- a/crate/Cargo.toml +++ b/crate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soda_sol" -version = "0.0.6" +version = "0.0.7" edition = "2021" license = "Apache-2.0" description = "Generates Solana Projects from an IDL" diff --git a/ui/context/IDL/index.tsx b/ui/context/IDL/index.tsx index 4adddf6..efc018d 100644 --- a/ui/context/IDL/index.tsx +++ b/ui/context/IDL/index.tsx @@ -37,13 +37,15 @@ const IDLProvider = ({ children }: { children: ReactNode }) => { .then(() => { if (IDL.name === "Chewing Glass") { invoke("new_window", { target: "bubbles" }).catch(async (e) => { - await message(e, { title: "Error", type: "error" }); + console.log(e) + await message(e?.error ?? "Error open more windows", { title: "Error", type: "error" }); }); } setIDL(IDL); }) .catch(async (e) => { - await message(e, { title: "Error", type: "error" }); + console.log(e) + await message(e?.error ?? "Error setting IDL", { title: "Error", type: "error" }); }); }; diff --git a/ui/src-tauri/Cargo.lock b/ui/src-tauri/Cargo.lock index a0d92f2..b0c85ae 100644 --- a/ui/src-tauri/Cargo.lock +++ b/ui/src-tauri/Cargo.lock @@ -2367,7 +2367,9 @@ dependencies = [ [[package]] name = "soda_sol" -version = "0.0.6" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd32d9ac134802d8363d2bd3d5ced12eaefa659f230708774d3514cf7160f1e6" dependencies = [ "bincode", "handlebars", diff --git a/ui/src-tauri/Cargo.toml b/ui/src-tauri/Cargo.toml index b9743ed..afe1622 100644 --- a/ui/src-tauri/Cargo.toml +++ b/ui/src-tauri/Cargo.toml @@ -19,7 +19,7 @@ tauri = { version = "1.2.5", features = ["dialog-all", "fs-create-dir", "fs-read serde_json = "1.0.93" serde = "1.0.164" thiserror = "1.0.40" -soda_sol = { path="../../crate"} +soda_sol = "0.0.7" [features] # by default Tauri runs in production mode diff --git a/ui/src-tauri/src/error.rs b/ui/src-tauri/src/error.rs index 29613b1..293f3da 100644 --- a/ui/src-tauri/src/error.rs +++ b/ui/src-tauri/src/error.rs @@ -1,5 +1,5 @@ use std::sync::{MutexGuard, PoisonError}; - +use std::time::SystemTimeError; use crate::StateStruct; #[derive(thiserror::Error, Debug)] @@ -59,3 +59,11 @@ impl From for Error { } } } + +impl From for Error { + fn from(err: SystemTimeError) -> Error { + Error::CustomError { + message: err.to_string(), + } + } +} \ No newline at end of file diff --git a/ui/src-tauri/src/new_window.rs b/ui/src-tauri/src/new_window.rs index e458093..f42173a 100644 --- a/ui/src-tauri/src/new_window.rs +++ b/ui/src-tauri/src/new_window.rs @@ -1,8 +1,9 @@ +use std::time::{SystemTime, UNIX_EPOCH}; use crate::*; #[tauri::command] pub async fn new_window(handle: tauri::AppHandle, target: &str) -> Result<(), Error> { - tauri::WindowBuilder::new(&handle, target, tauri::WindowUrl::App(target.into())) + tauri::WindowBuilder::new(&handle, format!("{}{}", target, SystemTime::now().duration_since(UNIX_EPOCH)?.subsec_nanos()), tauri::WindowUrl::App(target.into())) .title(target) .inner_size(800.0, 700.0) .build()?; From 4264d065237587fdc2e4d029c6d1bc874bc2386b Mon Sep 17 00:00:00 2001 From: Marche Date: Thu, 27 Jul 2023 11:49:35 -0300 Subject: [PATCH 2/2] Update Version (#150) --- ui/package.json | 2 +- ui/src-tauri/Cargo.toml | 2 +- ui/src-tauri/tauri.conf.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/package.json b/ui/package.json index 50c38e6..0353468 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.1.1", + "version": "0.1.2", "private": true, "scripts": { "dev": "next dev", diff --git a/ui/src-tauri/Cargo.toml b/ui/src-tauri/Cargo.toml index afe1622..28c43e6 100644 --- a/ui/src-tauri/Cargo.toml +++ b/ui/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soda" -version = "0.1.1" +version = "0.1.2" description = "Generates source code from an IDL" authors = ["Juan Patricio Marchetto"] license = "Apache-2.0" diff --git a/ui/src-tauri/tauri.conf.json b/ui/src-tauri/tauri.conf.json index 9e552f8..cd68957 100644 --- a/ui/src-tauri/tauri.conf.json +++ b/ui/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "soda", - "version": "0.1.1" + "version": "0.1.2" }, "tauri": { "allowlist": {