diff --git a/src/vector/index.js b/src/vector/index.js index 9f1620516..d26e480e3 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -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. , document.getElementById('matrixchat')); } else if (validBrowser) { - UpdateChecker.start(); + const platform = PlatformPeg.get(); + platform.startUpdater(); + const MatrixChat = sdk.getComponent('structures.MatrixChat'); window.matrixChat = ReactDOM.render( , document.getElementById('matrixchat') ); diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index 76707d1d5..8e998402c 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -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. diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index 8397a7f70..c589af38b 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -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) { diff --git a/src/vector/updater.js b/src/vector/updater.js deleted file mode 100644 index 19d40b4f3..000000000 --- a/src/vector/updater.js +++ /dev/null @@ -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(); - } -};