From dcff0a3a51a62dada2d8078593b13c12c875da8f Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 7 Jan 2016 08:53:03 +0200 Subject: [PATCH] Clear interval --- js/main.js | 1 + js/main.min.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 067182d6..739f1f1b 100644 --- a/js/main.js +++ b/js/main.js @@ -1602,6 +1602,7 @@ BdWSocket.prototype.onError = function(e) { BdWSocket.prototype.onClose = function(e) { utils.log("Socket Closed - " + e.code + " : " + e.reason); + clearInterval(bdSocket.interval); bdws.start(); }; diff --git a/js/main.min.js b/js/main.min.js index 6acbfebc..a9552773 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -65,7 +65,7 @@ ThemeModule.prototype.loadThemes=function(){this.loadThemeData();$.each(bdthemes if(enabled){$("head").append('');}});};ThemeModule.prototype.handleTheme=function(checkbox){var cb=$(checkbox).children().find('input[type="checkbox"]');var enabled=!cb.is(":checked");var id=cb.attr("id").substring(2);cb.prop("checked",enabled);if(enabled){$("head").append('');themeCookie[id]=true;}else{$("#"+id).remove();themeCookie[id]=false;} this.saveThemeData();};ThemeModule.prototype.loadThemeData=function(){var cookie=$.cookie("bd-themes");if(cookie!=undefined){themeCookie=JSON.parse($.cookie("bd-themes"));}};ThemeModule.prototype.saveThemeData=function(){$.cookie("bd-themes",JSON.stringify(themeCookie),{expires:365,path:'/'});};var bdSocket;var bdws;function BdWSocket(){bdws=this;} BdWSocket.prototype.start=function(){var self=this;$.ajax({method:"GET",url:"https://discordapp.com/api/gateway",headers:{authorization:localStorage.token.match(/\"(.+)\"/)[1]},success:function(data){self.open(data.url);}});};BdWSocket.prototype.open=function(host){utils.log("Socket Host: "+host);try{bdSocket=new WebSocket(host);bdSocket.onopen=this.onOpen;bdSocket.onmessage=this.onMessage;bdSocket.onerror=this.onError;bdSocket.onclose=this.onClose;}catch(err){utils.log(err);}};BdWSocket.prototype.onOpen=function(){utils.log("Socket Open");var data={op:2,d:{token:JSON.parse(localStorage.getItem('token')),properties:JSON.parse(localStorage.getItem('superProperties')),v:3}};bdws.send(data);};BdWSocket.prototype.onMessage=function(e){var packet,data,type;try{packet=JSON.parse(e.data);data=packet.d;type=packet.t;}catch(err){utils.err(err);return;} -switch(type){case"READY":bdSocket.interval=setInterval(()=>bdws.send({op:1,d:Date.now()}),data.heartbeat_interval);utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",data);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",data);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",data);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",data);break;default:break;}};BdWSocket.prototype.onError=function(e){utils.log("Socket Error - "+e.message);};BdWSocket.prototype.onClose=function(e){utils.log("Socket Closed - "+e.code+" : "+e.reason);bdws.start();};BdWSocket.prototype.send=function(data){bdSocket.send(JSON.stringify(data));};BdWSocket.prototype.getSocket=function(){return bdSocket;};function BdApi(){} +switch(type){case"READY":bdSocket.interval=setInterval(()=>bdws.send({op:1,d:Date.now()}),data.heartbeat_interval);utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",data);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",data);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",data);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",data);break;default:break;}};BdWSocket.prototype.onError=function(e){utils.log("Socket Error - "+e.message);};BdWSocket.prototype.onClose=function(e){utils.log("Socket Closed - "+e.code+" : "+e.reason);clearInterval(bdSocket.interval);bdws.start();};BdWSocket.prototype.send=function(data){bdSocket.send(JSON.stringify(data));};BdWSocket.prototype.getSocket=function(){return bdSocket;};function BdApi(){} BdApi.joinServer=function(code){opublicServers.joinServer(code);};BdApi.injectCSS=function(id,css){$("head").append('') $("#"+id).html(css);};BdApi.clearCSS=function(id){$("#"+id).remove();};BdApi.getPlugin=function(name){if(bdplugins.hasOwnProperty(name)){return bdplugins[name]["plugin"];} return null;};BdApi.getIpc=function(){return betterDiscordIPC;};BdApi.getCore=function(){return mainCore;};BdApi.getUserIdByName=function(name){var users=$(".member-username");for(var i=0;i