Merge pull request #1757 from thelounge/xpaw/detached-sign-in
Do not keep sign-in and loader references in memory
This commit is contained in:
commit
c9da29f2fc
@ -6,8 +6,6 @@ const storage = require("../localStorage");
|
|||||||
const utils = require("../utils");
|
const utils = require("../utils");
|
||||||
const templates = require("../../views");
|
const templates = require("../../views");
|
||||||
|
|
||||||
const login = $("#sign-in").html(templates.windows.sign_in());
|
|
||||||
|
|
||||||
socket.on("auth", function(data) {
|
socket.on("auth", function(data) {
|
||||||
// If we reconnected and serverHash differs, that means the server restarted
|
// If we reconnected and serverHash differs, that means the server restarted
|
||||||
// And we will reload the page to grab the latest version
|
// And we will reload the page to grab the latest version
|
||||||
@ -18,12 +16,12 @@ socket.on("auth", function(data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const login = $("#sign-in");
|
||||||
|
|
||||||
|
if (data.serverHash > -1) {
|
||||||
utils.serverHash = data.serverHash;
|
utils.serverHash = data.serverHash;
|
||||||
|
|
||||||
let token;
|
login.html(templates.windows.sign_in());
|
||||||
const user = storage.get("user");
|
|
||||||
|
|
||||||
login.find(".btn").prop("disabled", false);
|
|
||||||
|
|
||||||
login.find("form").on("submit", function() {
|
login.find("form").on("submit", function() {
|
||||||
const form = $(this);
|
const form = $(this);
|
||||||
@ -41,6 +39,12 @@ socket.on("auth", function(data) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
login.find(".btn").prop("disabled", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
let token;
|
||||||
|
const user = storage.get("user");
|
||||||
|
|
||||||
if (!data.success) {
|
if (!data.success) {
|
||||||
if (login.length === 0) {
|
if (login.length === 0) {
|
||||||
|
@ -4,7 +4,6 @@ const $ = require("jquery");
|
|||||||
const io = require("socket.io-client");
|
const io = require("socket.io-client");
|
||||||
const utils = require("./utils");
|
const utils = require("./utils");
|
||||||
const path = window.location.pathname + "socket.io/";
|
const path = window.location.pathname + "socket.io/";
|
||||||
const status = $("#loading-page-message, #connection-error");
|
|
||||||
|
|
||||||
const socket = io({
|
const socket = io({
|
||||||
transports: $(document.body).data("transports"),
|
transports: $(document.body).data("transports"),
|
||||||
@ -18,11 +17,11 @@ socket.on("connect_error", handleDisconnect);
|
|||||||
socket.on("error", handleDisconnect);
|
socket.on("error", handleDisconnect);
|
||||||
|
|
||||||
socket.on("reconnecting", function(attempt) {
|
socket.on("reconnecting", function(attempt) {
|
||||||
status.text(`Reconnecting… (attempt ${attempt})`);
|
$("#loading-page-message, #connection-error").text(`Reconnecting… (attempt ${attempt})`);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connecting", function() {
|
socket.on("connecting", function() {
|
||||||
status.text("Connecting…");
|
$("#loading-page-message, #connection-error").text("Connecting…");
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect", function() {
|
socket.on("connect", function() {
|
||||||
@ -31,17 +30,17 @@ socket.on("connect", function() {
|
|||||||
// nothing is sent to the server that might have happened.
|
// nothing is sent to the server that might have happened.
|
||||||
socket.sendBuffer = [];
|
socket.sendBuffer = [];
|
||||||
|
|
||||||
status.text("Finalizing connection…");
|
$("#loading-page-message, #connection-error").text("Finalizing connection…");
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("authorized", function() {
|
socket.on("authorized", function() {
|
||||||
status.text("Loading messages…");
|
$("#loading-page-message, #connection-error").text("Loading messages…");
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleDisconnect(data) {
|
function handleDisconnect(data) {
|
||||||
const message = data.message || data;
|
const message = data.message || data;
|
||||||
|
|
||||||
status.text(`Waiting to reconnect… (${message})`).addClass("shown");
|
$("#loading-page-message, #connection-error").text(`Waiting to reconnect… (${message})`).addClass("shown");
|
||||||
$(".show-more-button, #input").prop("disabled", true);
|
$(".show-more-button, #input").prop("disabled", true);
|
||||||
$("#submit").hide();
|
$("#submit").hide();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user