mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-22 19:33:27 +01:00
Fix it
This commit is contained in:
parent
28e6f8a0f6
commit
8c8a1685b2
1 changed files with 7 additions and 4 deletions
|
@ -136,14 +136,17 @@ const useConnectionListeners = () => {
|
|||
};
|
||||
|
||||
const useAutoSubscribe = (subscriptions, selected) => {
|
||||
const [autoSubscribed, setAutoSubscribed] = useState(false);
|
||||
const [hasRun, setHasRun] = useState(false);
|
||||
const params = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
const loaded = subscriptions !== null && subscriptions !== undefined;
|
||||
const eligible = loaded && params.topic && !selected && !autoSubscribed;
|
||||
if (!loaded || hasRun) {
|
||||
return;
|
||||
}
|
||||
setHasRun(true);
|
||||
const eligible = params.topic && !selected;
|
||||
if (eligible) {
|
||||
setAutoSubscribed(true);
|
||||
const baseUrl = (params.baseUrl) ? expandSecureUrl(params.baseUrl) : window.location.origin;
|
||||
console.log(`[App] Auto-subscribing to ${topicUrl(baseUrl, params.topic)}`);
|
||||
(async () => {
|
||||
|
@ -151,7 +154,7 @@ const useAutoSubscribe = (subscriptions, selected) => {
|
|||
poller.pollInBackground(subscription); // Dangle!
|
||||
})();
|
||||
}
|
||||
}, [params, subscriptions, selected, autoSubscribed]);
|
||||
}, [params, subscriptions, selected, hasRun]);
|
||||
};
|
||||
|
||||
const updateTitle = (newNotificationsCount) => {
|
||||
|
|
Loading…
Reference in a new issue