Compare commits
No commits in common. "7637606d9c719f4b11148102d606a228c7bc16b8" and "d9ed4ba6265a00ccb0faf63bd2c8d74353125ec2" have entirely different histories.
7637606d9c
...
d9ed4ba626
@ -92,18 +92,6 @@ struct SurrealResponse {
|
|||||||
result: SurrealResult,
|
result: SurrealResult,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
struct SurrealResultError {
|
|
||||||
code: i32,
|
|
||||||
message: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
struct SurrealResponseError {
|
|
||||||
id: u32,
|
|
||||||
error: SurrealResultError,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
struct SurrealAction {
|
struct SurrealAction {
|
||||||
id: String,
|
id: String,
|
||||||
@ -273,8 +261,8 @@ pub fn init_surrealdb() {
|
|||||||
fn surrealdb_response(response: String) {
|
fn surrealdb_response(response: String) {
|
||||||
let response: SurrealResponse = match serde_json::from_str(&response) {
|
let response: SurrealResponse = match serde_json::from_str(&response) {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
Err(_) => {
|
Err(err) => {
|
||||||
handle_error(response);
|
log::warn!("{}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -294,26 +282,6 @@ fn surrealdb_response(response: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Function to execute when an error is returned from Surrealdb
|
|
||||||
fn handle_error(response: String) {
|
|
||||||
let response: SurrealResponseError = match serde_json::from_str(&response) {
|
|
||||||
Ok(res) => res,
|
|
||||||
Err(err) => {
|
|
||||||
log::warn!("{}", err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if response.id == 0 && response.error.code == -32000 {
|
|
||||||
let (_, _, remove_token) =
|
|
||||||
use_local_storage::<String, FromToStringCodec>("surrealdb-token");
|
|
||||||
let websocket = expect_context::<SurrealContext>();
|
|
||||||
|
|
||||||
remove_token();
|
|
||||||
websocket.set_loading.set(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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(
|
util::toast::add_toast(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user