Skip to content

Commit

Permalink
Merge branch 'release/2.15.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Apr 30, 2019
2 parents 1c96790 + a2afc4b commit 7ad28f3
Show file tree
Hide file tree
Showing 7 changed files with 315 additions and 278 deletions.
11 changes: 11 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<a name="2.15.3"></a>
## 2.15.3 (2019-04-30)


### Bug Fixes

- [#1198](https://github.com/RocketChat/Rocket.Chat.Electron/pull/1198) Add a module to handle deep links following the documentation
- [#1196](https://github.com/RocketChat/Rocket.Chat.Electron/pull/1196) Safely compute initials for server name on sidebars



<a name="2.15.2"></a>
## 2.15.2 (2019-04-16)

Expand Down
2 changes: 1 addition & 1 deletion electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"mas"
],
"icon": "build/icon.icns",
"bundleVersion": "48",
"bundleVersion": "49",
"helperBundleId": "chat.rocket.electron.helper",
"type": "distribution",
"artifactName": "rocketchat-${version}.${ext}",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rocketchat",
"productName": "Rocket.Chat",
"description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.",
"version": "2.15.2",
"version": "2.15.3",
"author": "Rocket.Chat Support <[email protected]>",
"copyright": "© 2019, Rocket.Chat",
"homepage": "https://rocket.chat",
Expand Down
24 changes: 4 additions & 20 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { app } from 'electron';
import querystring from 'querystring';
import url from 'url';
import appData from './main/appData';
import './main/basicAuth';
import { processDeepLink } from './main/deepLinks';
import './main/systemIdleTime';
import './main/updates';
import { getMainWindow } from './main/mainWindow';
Expand All @@ -17,21 +16,6 @@ export { default as notifications } from './main/notifications';
export { default as certificate } from './main/certificateStore';


function parseCommandLineArguments(args) {
args
.filter((arg) => /^rocketchat:\/\/./.test(arg))
.map((uri) => url.parse(uri))
.map(({ hostname, pathname, query }) => {
const { insecure } = querystring.parse(query);
return `${ insecure === 'true' ? 'http' : 'https' }://${ hostname }${ pathname || '' }`;
})
.slice(0, 1)
.forEach(async (serverUrl) => {
const mainWindow = await getMainWindow();
mainWindow.send('add-host', serverUrl);
});
}

function handleUncaughtException(error) {
console.error(error);
app.exit(1);
Expand Down Expand Up @@ -71,11 +55,11 @@ async function prepareApp() {

app.on('open-url', (event, url) => {
event.preventDefault();
parseCommandLineArguments([url]);
processDeepLink(url);
});

app.on('second-instance', (event, argv) => {
parseCommandLineArguments(argv.slice(2));
argv.slice(2).forEach(processDeepLink);
});
}

Expand All @@ -85,5 +69,5 @@ async function prepareApp() {
await i18n.initialize();
app.emit('start');
await getMainWindow();
parseCommandLineArguments(process.argv.slice(2));
process.argv.slice(2).forEach(processDeepLink);
})();
44 changes: 44 additions & 0 deletions src/main/deepLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import querystring from 'querystring';
import url from 'url';
import { getMainWindow } from './mainWindow';


const normalizeUrl = (hostUrl) => {
if (!/^https?:\/\//.test(hostUrl)) {
return `https://${ hostUrl }`;
}

return hostUrl;
};

const processAuth = async ({ host, token, userId }) => {
const mainWindow = await getMainWindow();
const hostUrl = normalizeUrl(host);
mainWindow.send('add-host', hostUrl, { token, userId });
};

const processRoom = async ({ host, rid, path }) => {
const mainWindow = await getMainWindow();
const hostUrl = normalizeUrl(host);
mainWindow.send('add-host', hostUrl);
mainWindow.send('open-room', hostUrl, { rid, path });
};

export const processDeepLink = (link) => {
const { protocol, hostname: action, query } = url.parse(link);

if (protocol !== 'rocketchat:') {
return;
}

switch (action) {
case 'auth': {
processAuth(querystring.parse(query));
break;
}
case 'room': {
processRoom(querystring.parse(query));
break;
}
}
};
2 changes: 1 addition & 1 deletion src/scripts/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SideBar extends EventEmitter {
.replace(url, parseUrl(url).hostname)
.split(/[^A-Za-z0-9]+/g)
.slice(0, 2)
.map((text) => text[0].toUpperCase())
.map((text) => text.slice(0, 1).toUpperCase())
.join('')
);
const bustingParam = Math.round(Date.now() / faviconCacheBustingTime);
Expand Down
Loading

0 comments on commit 7ad28f3

Please sign in to comment.