Compare commits

..

No commits in common. "0cbbafb6ec861ce1967676660f38baf7f88b6d51" and "ed2a93548a07767b74f633807c0b2c1abba78d07" have entirely different histories.

3 changed files with 2 additions and 19 deletions

View File

@ -17,7 +17,6 @@ leptos-use = "0.10.2"
serde = "1.0.196"
serde_json = "1.0.113"
rand = "0.8.5"
gloo-timers = "0.3.0"
# utils
# strum = { version = "0.25", features = ["derive", "strum_macros"] }

View File

@ -1,4 +1,3 @@
use crate::util;
use leptos::*;
use leptos_use::{core::ConnectionReadyState, use_websocket, UseWebsocketReturn};
use serde::{Deserialize, Serialize};
@ -159,11 +158,6 @@ fn surrealdb_response(response: String) {
/// Function to execute when DB signin is succesful
fn use_surrealdb(_response: SurrealResponse) {
util::toast::add_toast(
"Succesfully signed into DB".to_string(),
"success".to_string(),
);
let websocket = expect_context::<SurrealContext>();
websocket.set_authenticated.set(true);

View File

@ -1,4 +1,3 @@
use gloo_timers::future::TimeoutFuture;
use leptos::*;
use rand::distributions::{Alphanumeric, DistString};
@ -29,23 +28,14 @@ pub fn add_toast(text: String, option: String) {
let id = Alphanumeric.sample_string(&mut rand::thread_rng(), 4);
let mut vec = context.notifications.get();
vec.push(ToastNotification {
text,
option,
id: id.clone(),
});
vec.push(ToastNotification { text, option, id });
context.set_notifications.set(vec);
spawn_local(async {
TimeoutFuture::new(5000).await;
remove_toast(id);
});
}
pub fn remove_toast(id: String) {
let context = expect_context::<NotificationsContext>();
let mut vec = context.notifications.get_untracked();
let mut vec = context.notifications.get();
vec.retain(|x| x.id != id);
context.set_notifications.set(vec);
}