absorb updater.js into the Platforms, gets rid of pointless setInterval in Electron

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

(cherry picked from commit 24e8a30)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/4176/head
Michael Telatynski 2017-06-03 12:50:47 +01:00
parent 24a5297fc8
commit 0e6012ad45
4 changed files with 17 additions and 33 deletions

View File

@ -59,7 +59,6 @@ var sdk = require("matrix-react-sdk");
const PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
sdk.loadSkin(require('../component-index'));
var VectorConferenceHandler = require('../VectorConferenceHandler');
var UpdateChecker = require("./updater");
var q = require('q');
var request = require('browser-request');
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
@ -277,7 +276,9 @@ async function loadApp() {
Unable to load config file: please refresh the page to try again.
</div>, document.getElementById('matrixchat'));
} else if (validBrowser) {
UpdateChecker.start();
const platform = PlatformPeg.get();
platform.startUpdater();
const MatrixChat = sdk.getComponent('structures.MatrixChat');
window.matrixChat = ReactDOM.render(
<MatrixChat
@ -290,7 +291,7 @@ async function loadApp() {
enableGuest={true}
onLoadCompleted={onLoadCompleted}
initialScreenAfterLogin={getScreenFromLocation(window.location)}
defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()}
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
/>,
document.getElementById('matrixchat')
);

View File

@ -74,6 +74,12 @@ export default class VectorBasePlatform extends BasePlatform {
this._updateFavicon();
}
/**
* Begin update polling, if applicable
*/
startUpdater() {
}
/**
* Check for the availability of an update to the version of the
* app that's currently running.

View File

@ -26,6 +26,8 @@ import q from 'q';
import url from 'url';
import UAParser from 'ua-parser-js';
var POKE_RATE_MS = 10 * 60 * 1000; // 10 min
export default class WebPlatform extends VectorBasePlatform {
constructor() {
super();
@ -132,6 +134,11 @@ export default class WebPlatform extends VectorBasePlatform {
return this._getVersion();
}
startUpdater() {
this.pollForUpdate();
setInterval(this.pollForUpdate, POKE_RATE_MS);
}
pollForUpdate() {
this._getVersion().done((ver) => {
if (this.runningVersion === null) {

View File

@ -1,30 +0,0 @@
/*
Copyright 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
var POKE_RATE_MS = 10 * 60 * 1000; // 10 min
module.exports = {
start: function() {
module.exports.poll();
setInterval(module.exports.poll, POKE_RATE_MS);
},
poll: function() {
PlatformPeg.get().pollForUpdate();
}
};