mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +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 { t } from "./i18n.js";
|
||||||
import type { EntityChange } from "../server_types.js";
|
import type { EntityChange } from "../server_types.js";
|
||||||
import { WebSocketMessage } from "@triliumnext/commons";
|
import { WebSocketMessage } from "@triliumnext/commons";
|
||||||
|
import toast from "./toast.js";
|
||||||
|
|
||||||
type MessageHandler = (message: WebSocketMessage) => void;
|
type MessageHandler = (message: WebSocketMessage) => void;
|
||||||
let messageHandlers: MessageHandler[] = [];
|
let messageHandlers: MessageHandler[] = [];
|
||||||
@ -278,13 +279,17 @@ function connectWebSocket() {
|
|||||||
|
|
||||||
async function sendPing() {
|
async function sendPing() {
|
||||||
if (Date.now() - lastPingTs > 30000) {
|
if (Date.now() - lastPingTs > 30000) {
|
||||||
console.log(
|
console.warn(utils.now(), "Lost websocket connection to the backend");
|
||||||
utils.now(),
|
toast.showPersistent({
|
||||||
"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."
|
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) {
|
if (ws.readyState === ws.OPEN) {
|
||||||
|
toast.closePersistent("lost-websocket-connection");
|
||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "ping",
|
type: "ping",
|
||||||
|
@ -1787,7 +1787,9 @@
|
|||||||
"ws": {
|
"ws": {
|
||||||
"sync-check-failed": "Sync check failed!",
|
"sync-check-failed": "Sync check failed!",
|
||||||
"consistency-checks-failed": "Consistency checks failed! See logs for details.",
|
"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": {
|
"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?"
|
"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