Merge branch 'main' into custom-messages

pull/180/head
Philipp Heckel 2022-03-28 14:14:20 -04:00
commit b20df55b88
6 changed files with 21 additions and 37 deletions

View File

@ -39,6 +39,10 @@ the [build instructions](https://ntfy.sh/docs/develop/) for the server and the A
Or, if you'd like to help translate 🇩🇪 🇺🇸 🇧🇬, you can start immediately in Or, if you'd like to help translate 🇩🇪 🇺🇸 🇧🇬, you can start immediately in
[Hosted Weblate](https://hosted.weblate.org/projects/ntfy/). [Hosted Weblate](https://hosted.weblate.org/projects/ntfy/).
<a href="https://hosted.weblate.org/engage/ntfy/">
<img src="https://hosted.weblate.org/widgets/ntfy/-/multi-blue.svg" alt="Translation status" />
</a>
## Contact me ## Contact me
You can directly contact me **[on Discord](https://discord.gg/cT7ECsZj9w)** or [on Matrix](https://matrix.to/#/#ntfy:matrix.org) You can directly contact me **[on Discord](https://discord.gg/cT7ECsZj9w)** or [on Matrix](https://matrix.to/#/#ntfy:matrix.org)
(bridged from Discord), or via the [GitHub issues](https://github.com/binwiederhier/ntfy/issues), or find more contact information (bridged from Discord), or via the [GitHub issues](https://github.com/binwiederhier/ntfy/issues), or find more contact information

View File

@ -11,8 +11,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
* Download attachments to cache folder ([#181](https://github.com/binwiederhier/ntfy/issues/181)) * Download attachments to cache folder ([#181](https://github.com/binwiederhier/ntfy/issues/181))
* Regularly delete attachments for deleted notifications ([#142](https://github.com/binwiederhier/ntfy/issues/142)) * Regularly delete attachments for deleted notifications ([#142](https://github.com/binwiederhier/ntfy/issues/142))
* Translations to different languages ([#188](https://github.com/binwiederhier/ntfy/issues/188), thanks to * Translations to different languages ([#188](https://github.com/binwiederhier/ntfy/issues/188), thanks to
[@StoyanDimitrov](https://github.com/StoyanDimitrov) for initiating things, and thanks to [@comradekingu](https://github.com/comradekingu) [@StoyanDimitrov](https://github.com/StoyanDimitrov) for initiating things)
for refining some English language strings)
**Bugs:** **Bugs:**
@ -22,10 +21,14 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
**Translations:** **Translations:**
* English language improvements (thanks to [@comradekingu](https://github.com/comradekingu))
* Bulgarian (thanks to [@StoyanDimitrov](https://github.com/StoyanDimitrov)) * Bulgarian (thanks to [@StoyanDimitrov](https://github.com/StoyanDimitrov))
* Spanish (thanks to [@rogeliodh](https://github.com/rogeliodh)) * Spanish (thanks to [@rogeliodh](https://github.com/rogeliodh))
* Turkish (thanks to [@ersen](https://ersen.moe/)) * Turkish (thanks to [@ersen](https://ersen.moe/))
* Norwegian (thanks to [@comradekingu](https://github.com/comradekingu)) * Norwegian (thanks to [@comradekingu](https://github.com/comradekingu))
* German (thanks to [@cmeis](https://github.com/cmeis))
* Chinese (thanks to [@poi](https://hosted.weblate.org/user/poi))
* Dutch (thanks to [@diony](https://hosted.weblate.org/user/diony))
**Thanks:** **Thanks:**
@ -38,6 +41,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
* Do not allow comma in topic name in publish via GET endpoint (no ticket) * Do not allow comma in topic name in publish via GET endpoint (no ticket)
* Add "Access-Control-Allow-Origin: *" for attachments (no ticket, thanks to @FrameXX) * Add "Access-Control-Allow-Origin: *" for attachments (no ticket, thanks to @FrameXX)
* Make pruning run again in web app ([#186](https://github.com/binwiederhier/ntfy/issues/186))
**Documentation:** **Documentation:**

View File

@ -56,6 +56,4 @@ class Poller {
} }
const poller = new Poller(); const poller = new Poller();
poller.startWorker();
export default poller; export default poller;

View File

@ -1,7 +1,7 @@
import prefs from "./Prefs"; import prefs from "./Prefs";
import subscriptionManager from "./SubscriptionManager"; import subscriptionManager from "./SubscriptionManager";
const delayMillis = 15000; // 15 seconds const delayMillis = 25000; // 25 seconds
const intervalMillis = 1800000; // 30 minutes const intervalMillis = 1800000; // 30 minutes
class Pruner { class Pruner {
@ -35,6 +35,4 @@ class Pruner {
} }
const pruner = new Pruner(); const pruner = new Pruner();
pruner.startWorker();
export default pruner; export default pruner;

View File

@ -17,18 +17,13 @@ import {BrowserRouter, Outlet, Route, Routes, useOutletContext, useParams} from
import {expandUrl, topicUrl} from "../app/utils"; import {expandUrl, topicUrl} from "../app/utils";
import ErrorBoundary from "./ErrorBoundary"; import ErrorBoundary from "./ErrorBoundary";
import routes from "./routes"; import routes from "./routes";
import {useAutoSubscribe, useConnectionListeners, useLocalStorageMigration} from "./hooks"; import {useAutoSubscribe, useBackgroundProcesses, useConnectionListeners} from "./hooks";
import {Backdrop, ListItemIcon, ListItemText, Menu} from "@mui/material"; import {Backdrop} from "@mui/material";
import Paper from "@mui/material/Paper"; import Paper from "@mui/material/Paper";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import {MoreVert} from "@mui/icons-material"; import {MoreVert} from "@mui/icons-material";
import MenuItem from "@mui/material/MenuItem";
import TextField from "@mui/material/TextField"; import TextField from "@mui/material/TextField";
import SendIcon from "@mui/icons-material/Send"; import SendIcon from "@mui/icons-material/Send";
import priority1 from "../img/priority-1.svg";
import priority2 from "../img/priority-2.svg";
import priority4 from "../img/priority-4.svg";
import priority5 from "../img/priority-5.svg";
import api from "../app/Api"; import api from "../app/Api";
import SendDialog from "./SendDialog"; import SendDialog from "./SendDialog";
@ -80,7 +75,7 @@ const Layout = () => {
}); });
useConnectionListeners(subscriptions, users); useConnectionListeners(subscriptions, users);
useLocalStorageMigration(); useBackgroundProcesses();
useEffect(() => updateTitle(newNotificationsCount), [newNotificationsCount]); useEffect(() => updateTitle(newNotificationsCount), [newNotificationsCount]);
return ( return (

View File

@ -6,6 +6,7 @@ import notifier from "../app/Notifier";
import routes from "./routes"; import routes from "./routes";
import connectionManager from "../app/ConnectionManager"; import connectionManager from "../app/ConnectionManager";
import poller from "../app/Poller"; import poller from "../app/Poller";
import pruner from "../app/Pruner";
/** /**
* Wire connectionManager and subscriptionManager so that subscriptions are updated when the connection * Wire connectionManager and subscriptionManager so that subscriptions are updated when the connection
@ -67,29 +68,13 @@ export const useAutoSubscribe = (subscriptions, selected) => {
}; };
/** /**
* Migrate the 'topics' item in localStorage to the subscriptionManager. This is only done once to migrate away * Start the poller and the pruner. This is done in a side effect as opposed to just in Pruner.js
* from the old web UI. * and Poller.js, because side effect imports are not a thing in JS, and "Optimize imports" cleans
* up "unused" imports. See https://github.com/binwiederhier/ntfy/issues/186.
*/ */
export const useLocalStorageMigration = () => { export const useBackgroundProcesses = () => {
const [hasRun, setHasRun] = useState(false);
useEffect(() => { useEffect(() => {
if (hasRun) { poller.startWorker();
return; pruner.startWorker();
}
const topicsStr = localStorage.getItem("topics");
if (topicsStr) {
const topics = JSON.parse(topicsStr).filter(topic => topic !== "");
if (topics.length > 0) {
(async () => {
for (const topic of topics) {
const baseUrl = window.location.origin;
const subscription = await subscriptionManager.add(baseUrl, topic);
poller.pollInBackground(subscription); // Dangle!
}
localStorage.removeItem("topics");
})();
}
}
setHasRun(true);
}, []); }, []);
} }