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 {
|
||||
constructor(token) {
|
||||
this.ws = new WebSocket(`ws://${window.location.hostname}/gateway?v=2`);
|
||||
constructor(token, gatewayUrl) {
|
||||
this.ws = new WebSocket(gatewayUrl);
|
||||
|
||||
this.handshakeCompleted = false;
|
||||
this.sessionInformation = null;
|
||||
|
@ -116,8 +116,8 @@ GatewayConnection.prototype.fire = function(eventName, ...args) {
|
|||
|
||||
|
||||
class AppState {
|
||||
constructor(token) {
|
||||
this.connection = new GatewayConnection(token);
|
||||
constructor(token, gatewayUrl) {
|
||||
this.connection = new GatewayConnection(token, gatewayUrl);
|
||||
this.tc = new Tricarbon();
|
||||
|
||||
this.elements = {
|
||||
|
@ -201,5 +201,6 @@ AppState.prototype.renderSidebar = function(channels) {
|
|||
|
||||
let app;
|
||||
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