Files
rustpad/static/js/connection-state.js
T
2026-09-17 13:11:37 +02:00

17 lines
617 B
JavaScript

/*
* Copyright (C) 2026 Mateusz Gruszczyński @linuxiarz.pl
* Source-Available Code / Dual-Licensed.
*
* Free for non-commercial and evaluation use under terms of BSL/GPLv3.
* Commercial or production use requires a valid paid license.
* See LICENSE file in repository root for details.
*/
export const CONNECTION_ERROR_AFTER_RECONNECT_ATTEMPTS = 5;
export function reconnectStatus(attempt, networkOnline = true) {
const normalizedAttempt = Math.max(0, Number(attempt) || 0);
if (!networkOnline || normalizedAttempt < CONNECTION_ERROR_AFTER_RECONNECT_ATTEMPTS) return "reconnecting";
return "error";
}