mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
feat(ws): add a warning toast if websocket gets disconnected
This commit is contained in:
parent
619888847b
commit
59ce8b912d
@ -7,6 +7,7 @@ import appContext from "../components/app_context.js";
|
||||
import { t } from "./i18n.js";
|
||||
import type { EntityChange } from "../server_types.js";
|
||||
import { WebSocketMessage } from "@triliumnext/commons";
|
||||
import toast from "./toast.js";
|
||||
|
||||
type MessageHandler = (message: WebSocketMessage) => void;
|
||||
let messageHandlers: MessageHandler[] = [];
|
||||
@ -278,13 +279,17 @@ function connectWebSocket() {
|
||||
|
||||
async function sendPing() {
|
||||
if (Date.now() - lastPingTs > 30000) {
|
||||
console.log(
|
||||
utils.now(),
|
||||
"Lost websocket connection to the backend. If you keep having this issue repeatedly, you might want to check your reverse proxy (nginx, apache) configuration and allow/unblock WebSocket."
|
||||
);
|
||||
console.warn(utils.now(), "Lost websocket connection to the backend");
|
||||
toast.showPersistent({
|
||||
id: "lost-websocket-connection",
|
||||
title: t("ws.lost-websocket-connection-title"),
|
||||
message: t("ws.lost-websocket-connection-message"),
|
||||
icon: "no-signal"
|
||||
});
|
||||
}
|
||||
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
toast.closePersistent("lost-websocket-connection");
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: "ping",
|
||||
|
@ -1787,7 +1787,9 @@
|
||||
"ws": {
|
||||
"sync-check-failed": "Sync check failed!",
|
||||
"consistency-checks-failed": "Consistency checks failed! See logs for details.",
|
||||
"encountered-error": "Encountered error \"{{message}}\", check out the console."
|
||||
"encountered-error": "Encountered error \"{{message}}\", check out the console.",
|
||||
"lost-websocket-connection-title": "Lost connection to the server",
|
||||
"lost-websocket-connection-message": "Check your reverse proxy (e.g. nginx or Apache) configuration to ensure WebSocket connections are properly allowed and not being blocked."
|
||||
},
|
||||
"hoisted_note": {
|
||||
"confirm_unhoisting": "Requested note '{{requestedNote}}' is outside of hoisted note '{{hoistedNote}}' subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?"
|
||||
|
Loading…
x
Reference in New Issue
Block a user