mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 05:24:50 +08:00
removed reconnection attempts, added manual reconnect button
This commit is contained in:
parent
83c9815687
commit
b80bb93cfd
3 changed files with 16 additions and 24 deletions
|
|
@ -24,11 +24,9 @@ export let socket = io(
|
|||
// socket: io("http://localhost:3000", {
|
||||
autoConnect: false,
|
||||
secure: true,
|
||||
reconnectionAttempts: 1,
|
||||
reconnectionAttempts: 0,
|
||||
}
|
||||
);
|
||||
export let reconnectionAttempts = 0;
|
||||
export let maxReconnectionAttempts = 1;
|
||||
export let activePage = "preloader";
|
||||
export let pageTransition = false;
|
||||
export let expectedVersion = "0.9.4";
|
||||
|
|
@ -977,7 +975,6 @@ async function insertImageEmoji(text) {
|
|||
socket.on("connect", (f) => {
|
||||
UpdateConfig.setTimerStyle("mini", true);
|
||||
state = 1;
|
||||
reconnectionAttempts = 0;
|
||||
Notifications.add("Connected to Tribe", 1);
|
||||
let name = "Guest";
|
||||
if (firebase.auth().currentUser !== null) {
|
||||
|
|
@ -1047,34 +1044,20 @@ socket.on("connect_failed", (f) => {
|
|||
changeActiveSubpage("preloader");
|
||||
// $(".pageTribe .preloader div").removeClass("hidden");
|
||||
// $(".pageTribe .preloader").removeClass("hidden").css("opacity", 1);
|
||||
reconnectionAttempts++;
|
||||
if (reconnectionAttempts >= maxReconnectionAttempts) {
|
||||
$(".pageTribe .preloader .icon").html(`<i class="fas fa-fw fa-times"></i>`);
|
||||
$(".pageTribe .preloader .text").text(
|
||||
`Could not connect to Tribe server: ${f.message}`
|
||||
);
|
||||
} else {
|
||||
$(".pageTribe .preloader .text").text("Connection failed. Retrying");
|
||||
Notifications.add("Tribe connection error: " + f.message, -1);
|
||||
}
|
||||
$(".pageTribe .preloader .icon").html(`<i class="fas fa-fw fa-times"></i>`);
|
||||
$(".pageTribe .preloader .text").text(`Connection failed`);
|
||||
$(".pageTribe .preloader .reconnectButton").removeClass(`hidden`);
|
||||
});
|
||||
|
||||
socket.on("connect_error", (f) => {
|
||||
state = -1;
|
||||
reconnectionAttempts++;
|
||||
console.error(f);
|
||||
changeActiveSubpage("preloader");
|
||||
// $(".pageTribe .preloader div").removeClass("hidden");
|
||||
// $(".pageTribe .preloader").removeClass("hidden").css("opacity", 1);
|
||||
if (reconnectionAttempts >= maxReconnectionAttempts) {
|
||||
$(".pageTribe .preloader .icon").html(`<i class="fas fa-fw fa-times"></i>`);
|
||||
$(".pageTribe .preloader .text").text(
|
||||
`Could not connect to Tribe server: ${f.message}`
|
||||
);
|
||||
} else {
|
||||
$(".pageTribe .preloader .text").text("Connection error. Retrying");
|
||||
Notifications.add("Tribe connection error: " + f.message, -1);
|
||||
}
|
||||
$(".pageTribe .preloader .icon").html(`<i class="fas fa-fw fa-times"></i>`);
|
||||
$(".pageTribe .preloader .text").text(`Connection error`);
|
||||
$(".pageTribe .preloader .reconnectButton").removeClass(`hidden`);
|
||||
});
|
||||
|
||||
socket.on("mp_room_joined", (data) => {
|
||||
|
|
@ -1848,6 +1831,11 @@ $(".pageTest #result .tribeResultChat .chat .input input").keyup((e) => {
|
|||
}
|
||||
});
|
||||
|
||||
$(".pageTribe .preloader .reconnectButton").click((e) => {
|
||||
$(".pageTribe .preloader .reconnectButton").addClass(`hidden`);
|
||||
init();
|
||||
});
|
||||
|
||||
$(".pageTribe .lobby .chat .input input").keyup((e) => {
|
||||
if (e.keyCode === 13) {
|
||||
let msg = $(".pageTribe .lobby .chat .input input").val();
|
||||
|
|
|
|||
|
|
@ -3591,6 +3591,9 @@ key {
|
|||
font-size: 1rem;
|
||||
color: var(--sub-color);
|
||||
}
|
||||
.button {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
.prelobby {
|
||||
display: grid;
|
||||
|
|
|
|||
|
|
@ -3897,6 +3897,7 @@
|
|||
<i class="fas fa-fw fa-spin fa-circle-notch"></i>
|
||||
</div>
|
||||
<div class="text">Waiting for login</div>
|
||||
<div class="reconnectButton button hidden">Retry</div>
|
||||
</div>
|
||||
|
||||
<div class="prelobby hidden">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue