Compare commits
No commits in common. "0cbbafb6ec861ce1967676660f38baf7f88b6d51" and "ed2a93548a07767b74f633807c0b2c1abba78d07" have entirely different histories.
0cbbafb6ec
...
ed2a93548a
@ -17,7 +17,6 @@ leptos-use = "0.10.2"
|
|||||||
serde = "1.0.196"
|
serde = "1.0.196"
|
||||||
serde_json = "1.0.113"
|
serde_json = "1.0.113"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
gloo-timers = "0.3.0"
|
|
||||||
|
|
||||||
# utils
|
# utils
|
||||||
# strum = { version = "0.25", features = ["derive", "strum_macros"] }
|
# strum = { version = "0.25", features = ["derive", "strum_macros"] }
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::util;
|
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_use::{core::ConnectionReadyState, use_websocket, UseWebsocketReturn};
|
use leptos_use::{core::ConnectionReadyState, use_websocket, UseWebsocketReturn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -159,11 +158,6 @@ fn surrealdb_response(response: String) {
|
|||||||
|
|
||||||
/// Function to execute when DB signin is succesful
|
/// Function to execute when DB signin is succesful
|
||||||
fn use_surrealdb(_response: SurrealResponse) {
|
fn use_surrealdb(_response: SurrealResponse) {
|
||||||
util::toast::add_toast(
|
|
||||||
"Succesfully signed into DB".to_string(),
|
|
||||||
"success".to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let websocket = expect_context::<SurrealContext>();
|
let websocket = expect_context::<SurrealContext>();
|
||||||
|
|
||||||
websocket.set_authenticated.set(true);
|
websocket.set_authenticated.set(true);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use gloo_timers::future::TimeoutFuture;
|
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use rand::distributions::{Alphanumeric, DistString};
|
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 id = Alphanumeric.sample_string(&mut rand::thread_rng(), 4);
|
||||||
|
|
||||||
let mut vec = context.notifications.get();
|
let mut vec = context.notifications.get();
|
||||||
vec.push(ToastNotification {
|
vec.push(ToastNotification { text, option, id });
|
||||||
text,
|
|
||||||
option,
|
|
||||||
id: id.clone(),
|
|
||||||
});
|
|
||||||
context.set_notifications.set(vec);
|
context.set_notifications.set(vec);
|
||||||
|
|
||||||
spawn_local(async {
|
|
||||||
TimeoutFuture::new(5000).await;
|
|
||||||
remove_toast(id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_toast(id: String) {
|
pub fn remove_toast(id: String) {
|
||||||
let context = expect_context::<NotificationsContext>();
|
let context = expect_context::<NotificationsContext>();
|
||||||
|
|
||||||
let mut vec = context.notifications.get_untracked();
|
let mut vec = context.notifications.get();
|
||||||
vec.retain(|x| x.id != id);
|
vec.retain(|x| x.id != id);
|
||||||
context.set_notifications.set(vec);
|
context.set_notifications.set(vec);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user