feat: added storing if the preview popup was already shown this session
This commit is contained in:
parent
21a3b81044
commit
2c6c529cc6
|
@ -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",
|
||||||
|
|
|
@ -21,4 +21,5 @@ wasm-bindgen = "0.2.87"
|
||||||
wasm-bindgen-futures = "0.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"
|
22
src/main.rs
22
src/main.rs
|
@ -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.");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue