Updater runs every 30 minutes

This commit is contained in:
Jiiks 2018-02-14 22:15:27 +02:00
parent 2962d1fc9f
commit eb9e3dd4c6
4 changed files with 47 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import { ClientLogger as Logger, ClientIPC } from 'common';
class BetterDiscord {
constructor() {
window.bdglobals = Globals;
window.ClientIPC = ClientIPC;
window.css = CssEditor;
window.pm = PluginManager;

View File

@ -12,6 +12,7 @@
import { Events, SocketProxy, EventHook, CssEditor } from 'modules';
import { ProfileBadges } from 'ui';
import Updater from './updater';
export default class {
@ -20,7 +21,8 @@ export default class {
new ProfileBadges(),
new SocketProxy(),
new EventHook(),
CssEditor
CssEditor,
new Updater()
]);
}

View File

@ -0,0 +1,41 @@
/**
* BetterDiscord Updater Module
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import Events from './events';
import Globals from './globals';
import { $ } from 'vendor';
import { ClientLogger as Logger } from 'common';
export default class {
constructor() {
window.updater = this;
this.init = this.init.bind(this);
this.checkForUpdates = this.checkForUpdates.bind(this);
}
get interval() {
return 60 * 1000 * 30;
}
init() {
setInterval(this.checkForUpdates, this.interval);
}
checkForUpdates() {
Events.emit('update-check-start');
Logger.info('Updater', 'Checking for updates');
$.get('https://raw.githubusercontent.com/JsSucks/BetterDiscordApp/master/package.json', e => {
const parse = JSON.parse(e);
Logger.info('Updater', `Latest Version: ${parse.version} - Current Version: ${Globals.getObject('version')}`);
});
}
}

View File

@ -12,6 +12,8 @@ import WebpackModules from './webpackmodules';
import jQuery from 'jquery';
import lodash from 'lodash';
export { jQuery as $ };
export default class {
static get jQuery() {