feat: added storing if the preview popup was already shown this session

This commit is contained in:
antifallobst 2023-10-08 15:40:32 +02:00
parent 21a3b81044
commit 2c6c529cc6
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
3 changed files with 21 additions and 5 deletions

1
Cargo.lock generated
View File

@ -131,6 +131,7 @@ dependencies = [
"futures-channel", "futures-channel",
"gloo 0.10.0", "gloo 0.10.0",
"gloo-net 0.4.0", "gloo-net 0.4.0",
"gloo-storage 0.3.0",
"serde", "serde",
"serde_json", "serde_json",
"wasm-bindgen", "wasm-bindgen",

View File

@ -22,3 +22,4 @@ wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3.64", features = ["HtmlInputElement", "HtmlDocument"] } web-sys = { version = "0.3.64", features = ["HtmlInputElement", "HtmlDocument"] }
gloo = "0.10.0" gloo = "0.10.0"
gloo-net = "0.4.0" gloo-net = "0.4.0"
gloo-storage = "0.3.0"

View File

@ -2,10 +2,10 @@ mod backend;
mod content; mod content;
mod topbar; mod topbar;
use anyhow::Result;
use backend::Session; use backend::Session;
use content::{about::About, error, home::Home}; use content::{about::About, error, home::Home};
use gloo::dialogs::alert; use gloo::dialogs::alert;
use gloo_storage::{SessionStorage, Storage};
use std::ops::Deref; use std::ops::Deref;
use topbar::TopBar; use topbar::TopBar;
use yew::prelude::*; use yew::prelude::*;
@ -70,8 +70,22 @@ fn App() -> Html {
} }
fn main() { fn main() {
if option_env!("NC_BETA_BUILD").is_some() { preview_alert();
alert("This is a beta preview!\nThe UI and the backend are subjects to change. Data persistence can't be guaranteed.");
}
yew::Renderer::<App>::new().render(); yew::Renderer::<App>::new().render();
} }
fn preview_alert() {
if option_env!("NC_BETA_BUILD").is_none() {
return;
}
if let Ok(value) = SessionStorage::get::<bool>("nc-preview-alert-shown") {
if value {
return;
}
}
SessionStorage::set("nc-preview-alert-shown", true).expect("Failed to set session storage!");
alert("This is a beta preview!\nThe UI and the backend are subjects to change. Data persistence can't be guaranteed.");
}