mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-28 18:14:08 +08:00
fix(onboarding): Receive user info correctly
This commit is contained in:
parent
73a1fbf76b
commit
d1ba5a3e2b
1 changed files with 13 additions and 9 deletions
|
@ -126,22 +126,26 @@ export default class AuthenticatePage extends React.Component {
|
|||
|
||||
webviewDidFinishLoad = () => {
|
||||
// this is sometimes called right after did-fail-load
|
||||
if (this.state.error) { return; }
|
||||
|
||||
const js = `
|
||||
var a = document.querySelector('#pro-account');
|
||||
result = a ? a.innerText : null;
|
||||
var el = document.querySelector('.open-external');
|
||||
if (el) {el.addEventListener('click', function(event) {console.log(this.href); event.preventDefault(); return false;})}
|
||||
`;
|
||||
if (this.state.error) return;
|
||||
|
||||
const webview = ReactDOM.findDOMNode(this.refs.webview);
|
||||
webview.executeJavaScript(js, false, (result) => {
|
||||
|
||||
const receiveUserInfo = `
|
||||
var a = document.querySelector('#pro-account');
|
||||
result = a ? a.innerText : null;
|
||||
`;
|
||||
webview.executeJavaScript(receiveUserInfo, false, (result) => {
|
||||
this.setState({ready: true, webviewLoading: false});
|
||||
if (result !== null) {
|
||||
OnboardingActions.authenticationJSONReceived(JSON.parse(result));
|
||||
}
|
||||
});
|
||||
|
||||
const openExternalLink = `
|
||||
var el = document.querySelector('.open-external');
|
||||
if (el) {el.addEventListener('click', function(event) {console.log(this.href); event.preventDefault(); return false;})}
|
||||
`;
|
||||
webview.executeJavaScript(openExternalLink);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in a new issue