[FIX] Blockstack errors in IE 11 (#12338)

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).
pull/12374/head
Tasso Evangelista 7 years ago committed by Guilherme Gazzo
parent 6ad440f486
commit b7b73a911f
  1. 2
      .circleci/config.yml
  2. 8
      packages/rocketchat-blockstack/client/main.js
  3. 3
      packages/rocketchat-blockstack/client/routes.js

@ -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

@ -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');
@ -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);
}
@ -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);

@ -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({
@ -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');

Loading…
Cancel
Save