#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import { useEffect, useState } from "react";
import { connectionModeService } from "@editor/services/connectionModeService";
import { useLocalProcessingOnly } from "@editor/hooks/useLocalProcessingOnly";
/** The bundled backend has no notification API; wait for the mode before polling. */
export function useNotificationsAvailable(): boolean {
const localOnly = useLocalProcessingOnly();
const [available, setAvailable] = useState(false);
useEffect(() => {
let current = true;
void connectionModeService.getCurrentMode().then((mode) => {
if (current) setAvailable(mode !== "local");
});
const unsubscribe = connectionModeService.subscribeToModeChanges((cfg) => {
current = false;
setAvailable(cfg.mode !== "local");
});
return () => {
current = false;
unsubscribe();
};
}, []);
return available && !localOnly;
}