From 5dc47541817f4ce603cf73d12e8bf9d035bc7cb8 Mon Sep 17 00:00:00 2001 From: Ivan Ip Date: Sun, 4 Dec 2022 03:10:24 +0000 Subject: [PATCH 1/7] Translated using Weblate (Chinese (Traditional)) Currently translated at 43.9% (83 of 189 strings) Translation: ntfy/Web app Translate-URL: https://hosted.weblate.org/projects/ntfy/web/zh_Hant/ --- web/public/static/langs/zh_Hant.json | 51 ++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/web/public/static/langs/zh_Hant.json b/web/public/static/langs/zh_Hant.json index 9da0e06b..09b9b489 100644 --- a/web/public/static/langs/zh_Hant.json +++ b/web/public/static/langs/zh_Hant.json @@ -10,15 +10,15 @@ "notifications_list_item": "通知", "notifications_mark_read": "標示已讀", "notifications_attachment_image": "附加圖片", - "notifications_attachment_copy_url_title": "複製附件URL到剪貼板", - "notifications_attachment_copy_url_button": "複製URL", + "notifications_attachment_copy_url_title": "複製附件 URL 到剪貼簿", + "notifications_attachment_copy_url_button": "複製 URL", "notifications_attachment_open_title": "前往 {{url}}", "notifications_attachment_open_button": "開啟附件", "notifications_attachment_link_expired": "下載連結已過期", "notifications_attachment_file_video": "影片檔案", "notifications_attachment_file_app": "Android 應用程式檔案", "notifications_attachment_file_document": "其他文件", - "notifications_click_copy_url_title": "複製連結URL到剪貼板", + "notifications_click_copy_url_title": "複製連結 URL 到剪貼板", "notifications_click_copy_url_button": "複製連結", "notifications_click_open_button": "開啟連結", "notifications_actions_not_supported": "網頁程式無法支援該動作", @@ -27,16 +27,16 @@ "notifications_none_for_topic_description": "如要寄送通知到此主題,請使用 PUT 或 POST 到此主題URL。", "notifications_none_for_any_title": "尚未收到任何通知。", "action_bar_settings": "設定", - "action_bar_send_test_notification": "寄送測試通知", + "action_bar_send_test_notification": "發送測試通知", "action_bar_clear_notifications": "清除所有通知", "action_bar_show_menu": "顯示選單", "nav_button_documentation": "文件", - "nav_button_publish_message": "發布通知", + "nav_button_publish_message": "發佈通知", "nav_button_muted": "通知已靜音", - "notifications_copied_to_clipboard": "複製到剪貼板", - "message_bar_publish": "發布訊息", - "message_bar_show_dialog": "顯示發布對話筐", - "message_bar_error_publishing": "無法發布通知", + "notifications_copied_to_clipboard": "已複製到剪貼簿", + "message_bar_publish": "發佈訊息", + "message_bar_show_dialog": "顯示發佈對話框", + "message_bar_error_publishing": "發佈通知時發生錯誤", "nav_topics_title": "訂閱主題", "nav_button_all_notifications": "所有通知", "nav_button_settings": "設定", @@ -50,7 +50,36 @@ "notifications_new_indicator": "新通知", "notifications_attachment_file_audio": "聲音檔案", "notifications_delete": "刪除", - "notifications_attachment_link_expires": "連結已過期 {{date}}", + "notifications_attachment_link_expires": "連結在 {{date}} 過期", "notifications_attachment_file_image": "圖片檔案", - "notifications_actions_open_url_title": "前往 {{url}}" + "notifications_actions_open_url_title": "前往 {{url}}", + "notifications_no_subscriptions_title": "你尚未有任何訂閱。", + "notifications_example": "範例", + "notifications_more_details": "你可以在 ntfy 網站或者技術文件中查看更多資訊。", + "notifications_loading": "載入中…", + "publish_dialog_title_topic": "發佈到 {{topic}}", + "publish_dialog_title_no_topic": "發佈通知", + "publish_dialog_progress_uploading": "上傳中…", + "publish_dialog_priority_label": "優先度", + "publish_dialog_email_label": "電郵地址", + "publish_dialog_filename_label": "檔案名稱", + "publish_dialog_button_cancel": "取消", + "publish_dialog_button_send": "傳送", + "publish_dialog_button_cancel_sending": "取消傳送", + "subscribe_dialog_subscribe_button_cancel": "取消", + "subscribe_dialog_subscribe_button_subscribe": "訂閱", + "emoji_picker_search_clear": "清除", + "subscribe_dialog_login_password_label": "密碼", + "subscribe_dialog_login_button_back": "返回", + "subscribe_dialog_login_button_login": "登入", + "prefs_notifications_delete_after_never": "從不", + "prefs_users_add_button": "新增使用者", + "prefs_users_dialog_password_label": "密碼", + "prefs_users_dialog_title_add": "新增使用者", + "prefs_users_dialog_button_save": "儲存", + "prefs_users_dialog_button_cancel": "取消", + "error_boundary_title": "歐買尬,ntfy 壞掉了", + "notifications_none_for_any_description": "要開始發送通知到一個主題,只需要對主題 URL 發送 HTTP PUT 或者 POST,例如:", + "notifications_no_subscriptions_description": "點選 「{{linktext}}」 連結以建立或訂閱主題。完成後,你就可以使用 HTTP PUT 或者 POST 發送通知到這裡了!", + "error_boundary_description": "很抱歉 ntfy 發生錯誤了。
如果你有時間,煩請到 Github 回報錯誤,或者到 Discord 或者 Matrix 聊天室裡面告訴我們。" } From b91fb3f5868a7b96715c7200d098f465ec47286e Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Thu, 8 Dec 2022 00:01:32 +0000 Subject: [PATCH 2/7] Add "Generate topic name" button to "Subscribe to topic" dialog Added a new button. When clicked it'll generate a random alphanumeric string and append to the current topic (or replace if empty). Signed-off-by: Yarden Shoham --- web/package-lock.json | 35 +++++++++++++++++++++------ web/package.json | 1 + web/public/static/langs/en.json | 1 + web/src/components/SubscribeDialog.js | 16 +++++++++++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index caf111eb..0d1a85c1 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -18,6 +18,7 @@ "i18next-browser-languagedetector": "^6.1.4", "i18next-http-backend": "^1.4.0", "js-base64": "^3.7.2", + "nanoid": "^4.0.0", "react": "latest", "react-dom": "latest", "react-i18next": "^11.16.2", @@ -11868,14 +11869,14 @@ } }, "node_modules/nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz", + "integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==", "bin": { - "nanoid": "bin/nanoid.cjs" + "nanoid": "bin/nanoid.js" }, "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + "node": "^14 || ^16 || >=18" } }, "node_modules/natural-compare": { @@ -13692,6 +13693,17 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -25412,9 +25424,9 @@ } }, "nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz", + "integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==" }, "natural-compare": { "version": "1.4.0", @@ -25873,6 +25885,13 @@ "nanoid": "^3.3.4", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" + }, + "dependencies": { + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + } } }, "postcss-attribute-case-insensitive": { diff --git a/web/package.json b/web/package.json index e97191b0..13bc146f 100644 --- a/web/package.json +++ b/web/package.json @@ -19,6 +19,7 @@ "i18next-browser-languagedetector": "^6.1.4", "i18next-http-backend": "^1.4.0", "js-base64": "^3.7.2", + "nanoid": "^4.0.0", "react": "latest", "react-dom": "latest", "react-i18next": "^11.16.2", diff --git a/web/public/static/langs/en.json b/web/public/static/langs/en.json index 4d12c072..92380c2c 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 62cfeb28..1a8c1b8d 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -15,8 +15,10 @@ import subscriptionManager from "../app/SubscriptionManager"; import poller from "../app/Poller"; import DialogFooter from "./DialogFooter"; import {useTranslation} from "react-i18next"; +import {customAlphabet} from 'nanoid/non-secure' const publicBaseUrl = "https://ntfy.sh"; +const randomAlphanumericString = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 21); const SubscribeDialog = (props) => { const [baseUrl, setBaseUrl] = useState(""); @@ -77,6 +79,17 @@ const SubscribePage = (props) => { console.log(`[SubscribeDialog] Successful login to ${topicUrl(baseUrl, topic)} for user ${username}`); props.onSuccess(); }; + const generateTopicName = () => { + const entropy = randomAlphanumericString(); + let newTopic = props.topic; + if (newTopic) { + newTopic += "-" + entropy; + } else { + const sliceIndex = entropy.length / 2; + newTopic = entropy.slice(0, sliceIndex) + "-" + entropy.slice(sliceIndex); + } + props.setTopic(newTopic); + } const handleUseAnotherChanged = (e) => { props.setBaseUrl(""); setAnotherServerVisible(e.target.checked); @@ -118,7 +131,8 @@ const SubscribePage = (props) => { maxLength: 64, "aria-label": t("subscribe_dialog_subscribe_topic_placeholder") }} - /> + /> +
Date: Thu, 8 Dec 2022 10:32:02 +0000 Subject: [PATCH 3/7] Place "Generate topic name" in the same line as the text field Signed-off-by: Yarden Shoham --- web/src/components/SubscribeDialog.js | 46 +++++++++++++++++---------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index 1a8c1b8d..61a26ffe 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -6,7 +6,7 @@ import Dialog from '@mui/material/Dialog'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogTitle from '@mui/material/DialogTitle'; -import {Autocomplete, Checkbox, FormControlLabel, useMediaQuery} from "@mui/material"; +import {Autocomplete, Checkbox, FormControlLabel, Grid, useMediaQuery} from "@mui/material"; import theme from "./theme"; import api from "../app/Api"; import {topicUrl, validTopic, validUrl} from "../app/utils"; @@ -53,6 +53,14 @@ const SubscribeDialog = (props) => { ); }; +const Row = (props) => { + return ( +
+ {props.children} +
+ ); +}; + const SubscribePage = (props) => { const { t } = useTranslation(); const [anotherServerVisible, setAnotherServerVisible] = useState(false); @@ -117,22 +125,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") + }} + /> + +
Date: Thu, 8 Dec 2022 10:42:28 +0000 Subject: [PATCH 4/7] Remove nanoid dependency Signed-off-by: Yarden Shoham --- web/package-lock.json | 35 ++++++--------------------- web/package.json | 1 - web/src/components/SubscribeDialog.js | 14 +++++++++-- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 0d1a85c1..caf111eb 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -18,7 +18,6 @@ "i18next-browser-languagedetector": "^6.1.4", "i18next-http-backend": "^1.4.0", "js-base64": "^3.7.2", - "nanoid": "^4.0.0", "react": "latest", "react-dom": "latest", "react-i18next": "^11.16.2", @@ -11869,14 +11868,14 @@ } }, "node_modules/nanoid": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz", - "integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", "bin": { - "nanoid": "bin/nanoid.js" + "nanoid": "bin/nanoid.cjs" }, "engines": { - "node": "^14 || ^16 || >=18" + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, "node_modules/natural-compare": { @@ -13693,17 +13692,6 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, - "node_modules/postcss/node_modules/nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -25424,9 +25412,9 @@ } }, "nanoid": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.0.tgz", - "integrity": "sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==" + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" }, "natural-compare": { "version": "1.4.0", @@ -25885,13 +25873,6 @@ "nanoid": "^3.3.4", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" - }, - "dependencies": { - "nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" - } } }, "postcss-attribute-case-insensitive": { diff --git a/web/package.json b/web/package.json index 13bc146f..e97191b0 100644 --- a/web/package.json +++ b/web/package.json @@ -19,7 +19,6 @@ "i18next-browser-languagedetector": "^6.1.4", "i18next-http-backend": "^1.4.0", "js-base64": "^3.7.2", - "nanoid": "^4.0.0", "react": "latest", "react-dom": "latest", "react-i18next": "^11.16.2", diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index 61a26ffe..e116f32c 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -15,10 +15,20 @@ import subscriptionManager from "../app/SubscriptionManager"; import poller from "../app/Poller"; import DialogFooter from "./DialogFooter"; import {useTranslation} from "react-i18next"; -import {customAlphabet} from 'nanoid/non-secure' const publicBaseUrl = "https://ntfy.sh"; -const randomAlphanumericString = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 21); + +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(""); From 71e46860acd2462599cc214868594259e30ff167 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Thu, 8 Dec 2022 11:07:16 +0000 Subject: [PATCH 5/7] Remove unused layouts Signed-off-by: Yarden Shoham --- web/src/components/SubscribeDialog.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index e116f32c..eb0f6ae8 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -6,7 +6,7 @@ import Dialog from '@mui/material/Dialog'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogTitle from '@mui/material/DialogTitle'; -import {Autocomplete, Checkbox, FormControlLabel, Grid, useMediaQuery} from "@mui/material"; +import {Autocomplete, Checkbox, FormControlLabel, useMediaQuery} from "@mui/material"; import theme from "./theme"; import api from "../app/Api"; import {topicUrl, validTopic, validUrl} from "../app/utils"; @@ -63,14 +63,6 @@ const SubscribeDialog = (props) => { ); }; -const Row = (props) => { - return ( -
- {props.children} -
- ); -}; - const SubscribePage = (props) => { const { t } = useTranslation(); const [anotherServerVisible, setAnotherServerVisible] = useState(false); From e0d6a0b974ad2210af128a03ed6288291c19179f Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Thu, 8 Dec 2022 11:54:37 +0000 Subject: [PATCH 6/7] Simplify logic Signed-off-by: Yarden Shoham --- web/src/components/SubscribeDialog.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index eb0f6ae8..30e4a3c2 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -89,17 +89,6 @@ const SubscribePage = (props) => { console.log(`[SubscribeDialog] Successful login to ${topicUrl(baseUrl, topic)} for user ${username}`); props.onSuccess(); }; - const generateTopicName = () => { - const entropy = randomAlphanumericString(); - let newTopic = props.topic; - if (newTopic) { - newTopic += "-" + entropy; - } else { - const sliceIndex = entropy.length / 2; - newTopic = entropy.slice(0, sliceIndex) + "-" + entropy.slice(sliceIndex); - } - props.setTopic(newTopic); - } const handleUseAnotherChanged = (e) => { props.setBaseUrl(""); setAnotherServerVisible(e.target.checked); @@ -143,7 +132,7 @@ const SubscribePage = (props) => { "aria-label": t("subscribe_dialog_subscribe_topic_placeholder") }} /> - From 18596ecc34d476e4f5f6695273a4e30dff94df7d Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Thu, 8 Dec 2022 09:16:59 -0500 Subject: [PATCH 7/7] Changelog --- docs/releases.md | 4 ++++ web/public/static/langs/en.json | 2 +- web/src/app/utils.js | 10 +++++++++- web/src/components/SubscribeDialog.js | 16 ++-------------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/releases.md b/docs/releases.md index 1e8fff71..cfb50825 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -4,6 +4,10 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release ## ntfy server v1.30.0 (UNRELEASED) +**Features:** + +* Web: Generate random topic name button ([#453](https://github.com/binwiederhier/ntfy/issues/453), thanks to [@yardenshoham](https://github.com/yardenshoham)) + **Bug fixes + maintenance:** * Remove `--env-topic` option from `ntfy publish` as per [deprecation](deprecations.md) (no ticket) diff --git a/web/public/static/langs/en.json b/web/public/static/langs/en.json index 92380c2c..6b831b79 100644 --- a/web/public/static/langs/en.json +++ b/web/public/static/langs/en.json @@ -129,7 +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_generate_topic_name": "Generate name", "subscribe_dialog_subscribe_button_cancel": "Cancel", "subscribe_dialog_subscribe_button_subscribe": "Subscribe", "subscribe_dialog_login_title": "Login required", diff --git a/web/src/app/utils.js b/web/src/app/utils.js index ffc359b5..8b64b2c1 100644 --- a/web/src/app/utils.js +++ b/web/src/app/utils.js @@ -94,7 +94,6 @@ export const unmatchedTags = (tags) => { else return tags.filter(tag => !(tag in emojis)); } - export const maybeWithBasicAuth = (headers, user) => { if (user) { headers['Authorization'] = `Basic ${encodeBase64(`${user.username}:${user.password}`)}`; @@ -241,3 +240,12 @@ export async function* fetchLinesIterator(fileURL, headers) { yield chunk.substr(startIndex); // last line didn't end in a newline char } } + +export const randomAlphanumericString = (len) => { + const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; + let id = ""; + for (let i = 0; i < len; i++) { + id += alphabet[(Math.random() * alphabet.length) | 0]; + } + return id; +} diff --git a/web/src/components/SubscribeDialog.js b/web/src/components/SubscribeDialog.js index 30e4a3c2..9e591c55 100644 --- a/web/src/components/SubscribeDialog.js +++ b/web/src/components/SubscribeDialog.js @@ -9,7 +9,7 @@ import DialogTitle from '@mui/material/DialogTitle'; import {Autocomplete, Checkbox, FormControlLabel, useMediaQuery} from "@mui/material"; import theme from "./theme"; import api from "../app/Api"; -import {topicUrl, validTopic, validUrl} from "../app/utils"; +import {randomAlphanumericString, topicUrl, validTopic, validUrl} from "../app/utils"; import userManager from "../app/UserManager"; import subscriptionManager from "../app/SubscriptionManager"; import poller from "../app/Poller"; @@ -18,18 +18,6 @@ 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(""); @@ -132,7 +120,7 @@ const SubscribePage = (props) => { "aria-label": t("subscribe_dialog_subscribe_topic_placeholder") }} /> -