forked from hippoz/brainlet
frontend: store gateway url as localstorage value
This commit is contained in:
parent
ccca54c0b1
commit
6d99951fe7
1 changed files with 6 additions and 5 deletions
|
@ -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"));
|
||||||
});
|
});
|
Loading…
Reference in a new issue