frontend: store gateway url as localstorage value

This commit is contained in:
hippoz 2021-03-22 21:08:52 +02:00
parent ccca54c0b1
commit 6d99951fe7
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -41,8 +41,8 @@ const getOpcodeByName = (name) => {
class GatewayConnection { class GatewayConnection {
constructor(token) { constructor(token, gatewayUrl) {
this.ws = new WebSocket(`ws://${window.location.hostname}/gateway?v=2`); this.ws = new WebSocket(gatewayUrl);
this.handshakeCompleted = false; this.handshakeCompleted = false;
this.sessionInformation = null; this.sessionInformation = null;
@ -116,8 +116,8 @@ GatewayConnection.prototype.fire = function(eventName, ...args) {
class AppState { class AppState {
constructor(token) { constructor(token, gatewayUrl) {
this.connection = new GatewayConnection(token); this.connection = new GatewayConnection(token, gatewayUrl);
this.tc = new Tricarbon(); this.tc = new Tricarbon();
this.elements = { this.elements = {
@ -201,5 +201,6 @@ AppState.prototype.renderSidebar = function(channels) {
let app; let app;
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
app = new AppState(localStorage.getItem("token")); if (!localStorage.getItem("gatewayUrl")) localStorage.setItem("gatewayUrl", `ws://${window.location.hostname}/gateway?v=2`);
app = new AppState(localStorage.getItem("token"), localStorage.getItem("gatewayUrl"));
}); });