diff --git a/web/public/static/langs/en.json b/web/public/static/langs/en.json index 4d12c07..92380c2 100644 --- a/web/public/static/langs/en.json +++ b/web/public/static/langs/en.json @@ -129,6 +129,7 @@ "subscribe_dialog_subscribe_topic_placeholder": "Topic name, e.g. phil_alerts", "subscribe_dialog_subscribe_use_another_label": "Use another server", "subscribe_dialog_subscribe_base_url_label": "Service URL", + "subscribe_dialog_subscribe_button_generate_topic_name": "Generate topic name", "subscribe_dialog_subscribe_button_cancel": "Cancel", "subscribe_dialog_subscribe_button_subscribe": "Subscribe", "subscribe_dialog_login_title": "Login required", diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index 62cfeb2..30e4a3c 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -18,6 +18,18 @@ import {useTranslation} from "react-i18next"; const publicBaseUrl = "https://ntfy.sh"; +const randomAlphanumericString = () => { + const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789'; + const size = 16; + + let id = ''; + let i = size; + while (i--) { + id += alphabet[(Math.random() * alphabet.length) | 0]; + } + return id; + } + const SubscribeDialog = (props) => { const [baseUrl, setBaseUrl] = useState(""); const [topic, setTopic] = useState(""); @@ -104,21 +116,26 @@ const SubscribePage = (props) => { {t("subscribe_dialog_subscribe_description")} - props.setTopic(ev.target.value)} - type="text" - fullWidth - variant="standard" - inputProps={{ - maxLength: 64, - "aria-label": t("subscribe_dialog_subscribe_topic_placeholder") - }} - /> +
+ props.setTopic(ev.target.value)} + type="text" + fullWidth + variant="standard" + inputProps={{ + maxLength: 64, + "aria-label": t("subscribe_dialog_subscribe_topic_placeholder") + }} + /> + +