Skip to content

Commit

Permalink
[FIX] Blockstack errors in IE 11 (#12338)
Browse files Browse the repository at this point in the history
Closes #12226
This pull request removes `blockstack` dependency from the browser's modules bundle using [dynamic-import](https://docs.meteor.com/packages/dynamic-import.html).
  • Loading branch information
tassoevan authored and ggazzo committed Oct 19, 2018
1 parent 6ad440f commit b7b73a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:

- run:
name: Build Rocket.Chat
environment:
TOOL_NODE_FLAGS: --max_old_space_size=4096
command: |
if [[ $CIRCLE_TAG ]]; then meteor reset; fi
set +e
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-blockstack/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { check, Match } from 'meteor/check';
import { Session } from 'meteor/session';

import './routes';
import { redirectToSignIn, signUserOut } from 'blockstack';

const handleError = (error) => error && Session.set('errorMessage', error.reason || 'Unknown error');

Expand All @@ -29,7 +27,8 @@ Meteor.loginWithBlockstack = (options, callback = handleError) => {
manifestURI: String,
}));

return redirectToSignIn(options.redirectURI, options.manifestURI, options.scopes);
import('blockstack/dist/blockstack').then(({ redirectToSignIn }) =>
redirectToSignIn(options.redirectURI, options.manifestURI, options.scopes));
} catch (err) {
callback.call(Meteor, err);
}
Expand All @@ -45,7 +44,8 @@ Meteor.logout = (...args) => {

if (serviceConfig && blockstackAuth) {
Session.delete('blockstack_auth');
signUserOut(window.location.href);
import('blockstack/dist/blockstack').then(({ signUserOut }) =>
signUserOut(window.location.href));
}

return meteorLogout(...args);
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-blockstack/client/routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { FlowRouter } from 'meteor/kadira:flow-router';
import blockstack from 'blockstack';

const blockstackLogin = (authResponse, userData = {}) => {
Accounts.callLoginMethod({
Expand All @@ -19,6 +18,8 @@ const blockstackLogin = (authResponse, userData = {}) => {
FlowRouter.route('/_blockstack/validate', {
name: 'blockstackValidate',
async action(params, queryParams) {
const blockstack = await import('blockstack/dist/blockstack');

if (Meteor.userId()) {
console.log('Blockstack Auth requested when already logged in. Reloading.');
return FlowRouter.go('home');
Expand Down

1 comment on commit b7b73a9

@MarekRzewuski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks guys! Rocket Chat works again on IE with this patch!

Please sign in to comment.