From 61c338a23358f340008f63a2b193d18e59529b87 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 2 May 2017 21:24:02 +0100 Subject: [PATCH 1/2] remove leading v in /version file so its semver and also then consistent with electron versioning Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- scripts/package.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/package.sh b/scripts/package.sh index 5c1fdd5e36..b3bc00bf03 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e @@ -22,7 +22,14 @@ cp config.sample.json webapp/ mkdir -p dist cp -r webapp vector-$version -echo $version > vector-$version/version + +# if $version looks like semver with leading v, strip it before writing to file +if [[ ${version} =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-.+)?$ ]]; then + echo ${version:1} > vector-$version/version +else + echo ${version} > vector-$version/version +fi + tar chvzf dist/vector-$version.tar.gz vector-$version rm -r vector-$version From 6367344181d4312fb0d18b89a3c022ee5da9ae94 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 2 May 2017 21:29:19 +0100 Subject: [PATCH 2/2] tidy and fix flow notation Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 22 ++++++------- src/vector/platform/VectorBasePlatform.js | 2 +- src/vector/platform/WebPlatform.js | 39 +++++++++++------------ 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 9c857e3524..82ef0b5168 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -20,13 +20,11 @@ limitations under the License. import VectorBasePlatform from './VectorBasePlatform'; import dis from 'matrix-react-sdk/lib/dispatcher'; import q from 'q'; - -const electron = require('electron'); -const remote = electron.remote; +import electron, {remote} from 'electron'; remote.autoUpdater.on('update-downloaded', onUpdateDownloaded); -function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { +function onUpdateDownloaded(ev: Event, releaseNotes: string, ver: string, date: Date, updateURL: string) { dis.dispatch({ action: 'new_version', currentVersion: remote.app.getVersion(), @@ -35,7 +33,7 @@ function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { }); } -function platformFriendlyName() { +function platformFriendlyName(): string { console.log(window.process); switch (window.process.platform) { case 'darwin': @@ -72,11 +70,11 @@ export default class ElectronPlatform extends VectorBasePlatform { } } - supportsNotifications() : boolean { + supportsNotifications(): boolean { return true; } - maySendNotifications() : boolean { + maySendNotifications(): boolean { return true; } @@ -100,7 +98,7 @@ export default class ElectronPlatform extends VectorBasePlatform { icon: avatarUrl, tag: 'vector', silent: true, // we play our own sounds - } + }, ); notification.onclick = function() { @@ -123,7 +121,7 @@ export default class ElectronPlatform extends VectorBasePlatform { notif.close(); } - getAppVersion() { + getAppVersion(): Promise { return q(remote.app.getVersion()); } @@ -140,15 +138,15 @@ export default class ElectronPlatform extends VectorBasePlatform { electron.ipcRenderer.send('install_update'); } - getDefaultDeviceDisplayName() { + getDefaultDeviceDisplayName(): string { return 'Riot Desktop on ' + platformFriendlyName(); } - screenCaptureErrorString() { + screenCaptureErrorString(): ?string { return null; } - requestNotificationPermission() : Promise { + requestNotificationPermission(): Promise { return q('granted'); } diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index 5240f3f583..1466b76ae3 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -44,7 +44,7 @@ export default class VectorBasePlatform extends BasePlatform { * Get a sensible default display name for the * device Vector is running on */ - getDefaultDeviceDisplayName() { + getDefaultDeviceDisplayName(): string { return "Unknown device"; } } diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index 5dc5505297..72ca19f06c 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -52,7 +52,7 @@ export default class WebPlatform extends VectorBasePlatform { } this.favicon.badge(notif, { - bgColor: bgColor + bgColor: bgColor, }); } catch (e) { console.warn(`Failed to set badge count: ${e.message}`); @@ -75,7 +75,7 @@ export default class WebPlatform extends VectorBasePlatform { * Returns true if the platform supports displaying * notifications, otherwise false. */ - supportsNotifications() : boolean { + supportsNotifications(): boolean { return Boolean(global.Notification); } @@ -83,8 +83,8 @@ export default class WebPlatform extends VectorBasePlatform { * Returns true if the application currently has permission * to display notifications. Otherwise false. */ - maySendNotifications() : boolean { - return global.Notification.permission == 'granted'; + maySendNotifications(): boolean { + return global.Notification.permission === 'granted'; } /** @@ -94,7 +94,7 @@ export default class WebPlatform extends VectorBasePlatform { * that is 'granted' if the user allowed the request or * 'denied' otherwise. */ - requestNotificationPermission() : Promise { + requestNotificationPermission(): Promise { // annoyingly, the latest spec says this returns a // promise, but this is only supported in Chrome 46 // and Firefox 47, so adapt the callback API. @@ -113,13 +113,13 @@ export default class WebPlatform extends VectorBasePlatform { icon: avatarUrl, tag: "vector", silent: true, // we play our own sounds - } + }, ); notification.onclick = function() { dis.dispatch({ action: 'view_room', - room_id: room.roomId + room_id: room.roomId, }); global.focus(); notification.close(); @@ -132,7 +132,7 @@ export default class WebPlatform extends VectorBasePlatform { }, 5 * 1000); } - _getVersion() { + _getVersion(): Promise { const deferred = q.defer(); // We add a cachebuster to the request to make sure that we know about @@ -148,19 +148,19 @@ export default class WebPlatform extends VectorBasePlatform { }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { - if (err == null) err = { status: response.status }; + if (err === null) err = { status: response.status }; deferred.reject(err); return; } const ver = body.trim(); deferred.resolve(ver); - } + }, ); return deferred.promise; } - getAppVersion() { + getAppVersion(): Promise { if (this.runningVersion !== null) { return q(this.runningVersion); } @@ -169,9 +169,9 @@ export default class WebPlatform extends VectorBasePlatform { pollForUpdate() { this._getVersion().done((ver) => { - if (this.runningVersion == null) { + if (this.runningVersion === null) { this.runningVersion = ver; - } else if (this.runningVersion != ver) { + } else if (this.runningVersion !== ver) { dis.dispatch({ action: 'new_version', currentVersion: this.runningVersion, @@ -187,19 +187,18 @@ export default class WebPlatform extends VectorBasePlatform { window.location.reload(); } - getDefaultDeviceDisplayName() { + getDefaultDeviceDisplayName(): string { // strip query-string and fragment from uri - let u = url.parse(window.location.href); + const u = url.parse(window.location.href); u.search = ""; u.hash = ""; - let app_name = u.format(); + const appName = u.format(); - let ua = new UAParser(); - return app_name + " via " + ua.getBrowser().name + - " on " + ua.getOS().name; + const ua = new UAParser(); + return `${appName} via ${ua.getBrowser().name} on ${ua.getOS().name}`; } - screenCaptureErrorString() { + screenCaptureErrorString(): ?string { // it won't work at all if you're not on HTTPS so whine whine whine if (!global.window || global.window.location.protocol !== "https:") { return "You need to be using HTTPS to place a screen-sharing call.";