From 21a3b81044526f1c79f4c36a35935cb98ed7dcc9 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 8 Oct 2023 14:22:16 +0200 Subject: [PATCH] feat: added a beta preview alert --- Dockerfile | 4 ++-- src/main.rs | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index a8c0698..c92f126 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ COPY Cargo.lock Cargo.toml index.html ./ COPY src ./src COPY style ./style -# Build for release. -RUN trunk build --release +# Build for preview release. +RUN NC_BETA_BUILD="" trunk build --release FROM nginx:latest diff --git a/src/main.rs b/src/main.rs index 3e5378f..deb0912 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod topbar; use anyhow::Result; use backend::Session; use content::{about::About, error, home::Home}; +use gloo::dialogs::alert; use std::ops::Deref; use topbar::TopBar; use yew::prelude::*; @@ -47,13 +48,11 @@ fn App() -> Html { let cloned_state = state.clone(); let callbacks = use_state(move || Callbacks { - sign_in: Callback::from( - move |token: String| { - let mut new_state = cloned_state.deref().clone(); - new_state.set_token(token); - cloned_state.set(new_state); - }, - ), + sign_in: Callback::from(move |token: String| { + let mut new_state = cloned_state.deref().clone(); + new_state.set_token(token); + cloned_state.set(new_state); + }), }); html! { @@ -71,5 +70,8 @@ fn App() -> Html { } fn main() { + if option_env!("NC_BETA_BUILD").is_some() { + alert("This is a beta preview!\nThe UI and the backend are subjects to change. Data persistence can't be guaranteed."); + } yew::Renderer::::new().render(); }