Skip to content

Commit 5762323

Browse files
authored
Merge branch 'develop' into t3chguy/electron_profiles
2 parents db602f2 + 89e5c4f commit 5762323

30 files changed

Lines changed: 391 additions & 130 deletions

‎.travis.yml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
language: node_js
22
node_js:
3-
- 6 # node v6, to match jenkins
3+
# make sure we work with a range of node versions.
4+
# As of the time of writing:
5+
# - 4.x is still in LTS (until April 2018), but some of our deps (notably
6+
# extract-zip) don't work with it
7+
# - 5.x has been EOLed for nearly a year.
8+
# - 6.x is the current 'LTS' version
9+
# - 7.x is the current 'current' version (until October 2017)
10+
#
11+
# see: https://github.com/nodejs/LTS/
12+
- 6.0
13+
- 6
14+
- 7
415
install:
516
- scripts/fetch-develop.deps.sh
617
- npm install

‎README.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ Building From Source
5555
Riot is a modular webapp built with modern ES6 and requires a npm build system
5656
to build.
5757

58-
1. Install or update `node.js` so that your `npm` is at least at version `2.0.0`
59-
1. Clone the repo: `git clone https://github.com/vector-im/riot-web.git`
60-
1. Switch to the riot-web directory: `cd riot-web`
58+
1. Install or update `node.js` so that your `node` is at least v6.0.0 (and `npm`
59+
is at least v3.8.6).
60+
1. Clone the repo: `git clone https://github.com/vector-im/riot-web.git`.
61+
1. Switch to the riot-web directory: `cd riot-web`.
6162
1. If you're using the `develop` branch, install the develop versions of the
6263
dependencies, as the released ones will be too old:
6364
```
6465
scripts/fetch-develop-deps.sh
6566
```
6667
Whenever you git pull on riot-web you will also probably need to force an update
6768
to these dependencies - the simplest way is to re-run the script, but you can also
68-
manually update and reuild them:
69+
manually update and rebuild them:
6970
```
7071
cd matrix-js-sdk
7172
git pull
@@ -85,10 +86,10 @@ to build.
8586
up-to-date. Or just use https://riot.im/develop - the continuous integration
8687
release of the develop branch.
8788
(Note that we don't reference the develop versions in git directly due to
88-
https://github.com/npm/npm/issues/3055)
89-
1. Install the prerequisites: `npm install`
89+
https://github.com/npm/npm/issues/3055.)
90+
1. Install the prerequisites: `npm install`.
9091
1. Configure the app by copying `config.sample.json` to `config.json` and
91-
modifying it (see below for details)
92+
modifying it (see below for details).
9293
1. `npm run dist` to build a tarball to deploy. Untaring this file will give
9394
a version-specific directory containing all the files that need to go on your
9495
web server.

‎config.sample.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
"servers": [
1111
"matrix.org"
1212
]
13+
},
14+
"piwik": {
15+
"url": "https://piwik.riot.im/",
16+
"siteId": 1
1317
}
1418
}

‎electron_app/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"author": "Vector Creations Ltd.",
88
"dependencies": {
99
"electron-window-state": "^4.1.0",
10+
"auto-launch": "^5.0.1",
1011
"minimist": "^1.2.0"
1112
}
1213
}

‎electron_app/riot.im/config.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@
1212
"servers": [
1313
"matrix.org"
1414
]
15+
},
16+
"piwik": {
17+
"url": "https://piwik.riot.im/",
18+
"siteId": 1
1519
}
1620
}

‎electron_app/src/electron-main.js‎

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if (checkSquirrelHooks()) return;
2323

2424
const argv = require('minimist')(process.argv);
2525
const electron = require('electron');
26+
const AutoLaunch = require('auto-launch');
2627

2728
const tray = require('./tray');
2829
const vectorMenu = require('./vectormenu');
@@ -50,47 +51,6 @@ const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
5051
let mainWindow = null;
5152
let appQuitting = false;
5253

53-
function safeOpenURL(target) {
54-
// openExternal passes the target to open/start/xdg-open,
55-
// so put fairly stringent limits on what can be opened
56-
// (for instance, open /bin/sh does indeed open a terminal
57-
// with a shell, albeit with no arguments)
58-
const parsedUrl = url.parse(target);
59-
if (PERMITTED_URL_SCHEMES.indexOf(parsedUrl.protocol) > -1) {
60-
// explicitly use the URL re-assembled by the url library,
61-
// so we know the url parser has understood all the parts
62-
// of the input string
63-
const newTarget = url.format(parsedUrl);
64-
electron.shell.openExternal(newTarget);
65-
}
66-
}
67-
68-
function onWindowOrNavigate(ev, target) {
69-
// always prevent the default: if something goes wrong,
70-
// we don't want to end up opening it in the electron
71-
// app, as we could end up opening any sort of random
72-
// url in a window that has node scripting access.
73-
ev.preventDefault();
74-
safeOpenURL(target);
75-
}
76-
77-
function onLinkContextMenu(ev, params) {
78-
const popupMenu = new electron.Menu();
79-
80-
popupMenu.append(new electron.MenuItem({
81-
label: params.linkURL,
82-
click() { safeOpenURL(params.linkURL); },
83-
}));
84-
85-
popupMenu.append(new electron.MenuItem({
86-
label: 'Copy Link Address',
87-
click() { electron.clipboard.writeText(params.linkURL); },
88-
}));
89-
90-
popupMenu.popup();
91-
ev.preventDefault();
92-
}
93-
9454
function installUpdate() {
9555
// for some reason, quitAndInstall does not fire the
9656
// before-quit event, so we need to set the flag here.
@@ -214,6 +174,47 @@ if (shouldQuit) {
214174
electron.app.exit();
215175
}
216176

177+
178+
const launcher = new AutoLaunch({
179+
name: vectorConfig.brand || 'Riot',
180+
isHidden: true,
181+
mac: {
182+
useLaunchAgent: true,
183+
},
184+
});
185+
186+
const settings = {
187+
'auto-launch': {
188+
get: launcher.isEnabled,
189+
set: function(bool) {
190+
if (bool) {
191+
return launcher.enable();
192+
} else {
193+
return launcher.disable();
194+
}
195+
},
196+
},
197+
};
198+
199+
electron.ipcMain.on('settings_get', async function(ev) {
200+
const data = {};
201+
202+
try {
203+
await Promise.all(Object.keys(settings).map(async function (setting) {
204+
data[setting] = await settings[setting].get();
205+
}));
206+
207+
ev.sender.send('settings', data);
208+
} catch(e) { console.error(e); }
209+
});
210+
211+
electron.ipcMain.on('settings_set', function(ev, key, value) {
212+
console.log(key, value);
213+
if (settings[key] && settings[key].set) {
214+
settings[key].set(value);
215+
}
216+
});
217+
217218
electron.app.on('ready', () => {
218219
if (vectorConfig.update_base_url) {
219220
console.log(`Starting auto update with base URL: ${vectorConfig.update_base_url}`);
@@ -243,6 +244,10 @@ electron.app.on('ready', () => {
243244
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
244245
electron.Menu.setApplicationMenu(vectorMenu);
245246

247+
// explicitly hide because setApplicationMenu on Linux otherwise shows...
248+
// https://github.com/electron/electron/issues/9621
249+
mainWindow.hide();
250+
246251
// Create trayIcon icon
247252
tray.create(mainWindow, {
248253
icon_path: iconPath,

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"build:compile": "npm run reskindex && babel --source-maps -d lib src",
3434
"build:bundle": "cross-env NODE_ENV=production webpack -p --progress",
3535
"build:bundle:dev": "webpack --optimize-occurence-order --progress",
36-
"build:electron": "npm run clean && npm run build && build -wml --ia32 --x64",
36+
"build:electron": "npm run clean && npm run build && npm run install:electron && build -wml --ia32 --x64",
3737
"build": "npm run reskindex && npm run build:res && npm run build:bundle",
3838
"build:dev": "npm run reskindex && npm run build:res && npm run build:bundle:dev",
3939
"dist": "scripts/package.sh",

‎scripts/fetch-develop.deps.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# the branch the current checkout is on, use that branch. Otherwise,
77
# use develop.
88

9+
set -e
10+
911
# Look in the many different CI env vars for which branch we're
1012
# building
1113
if [[ "$TRAVIS" == true ]]; then
@@ -40,13 +42,13 @@ dodep matrix-org matrix-react-sdk
4042
mkdir -p node_modules
4143
cd node_modules
4244

43-
rm -r matrix-js-sdk 2> /dev/null
45+
rm -r matrix-js-sdk 2> /dev/null || true
4446
ln -s ../matrix-js-sdk ./
4547
pushd matrix-js-sdk
4648
npm install
4749
popd
4850

49-
rm -r matrix-react-sdk 2> /dev/null
51+
rm -r matrix-react-sdk 2> /dev/null || true
5052
ln -s ../matrix-react-sdk ./
5153
pushd matrix-react-sdk
5254
mkdir -p node_modules

‎src/components/structures/CompatibilityPage.js‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
'use strict';
1818

1919
var React = require('react');
20+
import { _t, _tJsx } from 'matrix-react-sdk/lib/languageHandler';
2021

2122
module.exports = React.createClass({
2223
displayName: 'CompatibilityPage',
@@ -39,23 +40,37 @@ module.exports = React.createClass({
3940
return (
4041
<div className="mx_CompatibilityPage">
4142
<div className="mx_CompatibilityPage_box">
42-
<p>Sorry, your browser is <b>not</b> able to run Riot.</p>
43+
<p>{ _tJsx("Sorry, your browser is <b>not</b> able to run Riot.", /<b>(.*?)<\/b>/, (sub) => <b>{sub}</b>) } </p>
4344
<p>
44-
Riot uses many advanced browser features, some of which are not
45-
available or experimental in your current browser.
45+
{ _t("Riot uses many advanced browser features, some of which are not available or experimental in your current browser.") }
4646
</p>
4747
<p>
48-
Please install <a href="https://www.google.com/chrome">Chrome</a> or <a href="https://getfirefox.com">Firefox</a> for
49-
the best experience. <a href="http://apple.com/safari">Safari</a> and <a href="http://opera.com">Opera</a> work too.
48+
{ _tJsx('Please install <a href="https://www.google.com/chrome">Chrome</a> or <a href="https://getfirefox.com">Firefox</a> for the best experience.',
49+
[
50+
/<a href="https:\/\/www.google.com\/chrome">(.*?)<\/a>/,
51+
/<a href="https:\/\/getfirefox.com">(.*?)<\/a>/,
52+
],
53+
[
54+
(sub) => <a href="https://www.google.com/chrome">{sub}</a>,
55+
(sub) => <a href="https://getfirefox.com">{sub}</a>,
56+
]
57+
)}
58+
{ _tJsx('<a href="http://apple.com/safari">Safari</a> and <a href="http://opera.com">Opera</a> work too.',
59+
[
60+
/<a href="http:\/\/apple\.com\/safari">(.*?)<\/a>/,
61+
/<a href="http:\/\/opera\.com">(.*?)<\/a>/,
62+
],
63+
[
64+
(sub) => <a href="http://apple.com/safari">{sub}</a>,
65+
(sub) => <a href="http://opera.com">{sub}</a>,
66+
]
67+
)}
5068
</p>
5169
<p>
52-
With your current browser, the look and feel of the application may
53-
be completely incorrect, and some or all features may not function.
54-
If you want to try it anyway you can continue, but you are on your own
55-
in terms of any issues you may encounter!
70+
{ _t("With your current browser, the look and feel of the application may be completely incorrect, and some or all features may not function. If you want to try it anyway you can continue, but you are on your own in terms of any issues you may encounter!") }
5671
</p>
5772
<button onClick={this.onAccept}>
58-
I understand the risks and wish to continue
73+
{ _t("I understand the risks and wish to continue") }
5974
</button>
6075
</div>
6176
</div>

‎src/components/structures/RightPanel.js‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import sdk from 'matrix-react-sdk';
2222
import Matrix from "matrix-js-sdk";
2323
import dis from 'matrix-react-sdk/lib/dispatcher';
2424
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
25+
import Analytics from 'matrix-react-sdk/lib/Analytics';
2526
import rate_limited_func from 'matrix-react-sdk/lib/ratelimitedfunc';
2627
import Modal from 'matrix-react-sdk/lib/Modal';
2728
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
@@ -61,24 +62,26 @@ module.exports = React.createClass({
6162
return {
6263
phase: this.Phase.MemberInfo,
6364
member: member,
64-
}
65-
}
66-
else {
65+
};
66+
} else {
6767
return {
6868
phase: this.Phase.MemberList
69-
}
69+
};
7070
}
7171
},
7272

7373
onMemberListButtonClick: function() {
74+
Analytics.trackEvent('Right Panel', 'Member List Button', 'click');
7475
this.setState({ phase: this.Phase.MemberList });
7576
},
7677

7778
onFileListButtonClick: function() {
79+
Analytics.trackEvent('Right Panel', 'File List Button', 'click');
7880
this.setState({ phase: this.Phase.FilePanel });
7981
},
8082

8183
onNotificationListButtonClick: function() {
84+
Analytics.trackEvent('Right Panel', 'Notification List Button', 'click');
8285
this.setState({ phase: this.Phase.NotificationPanel });
8386
},
8487

@@ -93,7 +96,7 @@ module.exports = React.createClass({
9396
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
9497
Modal.createDialog(NeedToRegisterDialog, {
9598
title: _t('Please Register'),
96-
description: _t('Guest users can\'t invite users. Please register to invite') + '.'
99+
description: _t('Guest users can\'t invite users. Please register to invite.')
97100
});
98101
return;
99102
}
@@ -218,7 +221,7 @@ module.exports = React.createClass({
218221
<TintableSvg src="img/icons-notifications.svg" width="25" height="25"/>
219222
{ notificationsHighlight }
220223
</AccessibleButton>
221-
<div className="mx_RightPanel_headerButton mx_RightPanel_collapsebutton" title="Hide panel" onClick={ this.onCollapseClick }>
224+
<div className="mx_RightPanel_headerButton mx_RightPanel_collapsebutton" title={ _t("Hide panel") } onClick={ this.onCollapseClick }>
222225
<TintableSvg src="img/minimise.svg" width="10" height="16"/>
223226
</div>
224227
</div>;

0 commit comments

Comments
 (0)