Skip to content

Commit

Permalink
Minor to GOogle maps block
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Olaru committed Oct 1, 2019
1 parent d6e4273 commit 708ed64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/js/editor.blocks.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/blocks/google-map/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const {
Settings
} = wp.api.models;

// This is a GLOBAL function that, when present, gets called by the Google Maps script on authentication errors.
window.gm_authFailure = function() {
// This is a GLOBAL function that, when present, gets called by the Google Maps script on authentication errors.
window.googlemaps_authfailure = true;
window.dispatchEvent( new Event('novablock.googlemaps_authfailure') );
}

Expand All @@ -48,7 +49,7 @@ class Edit extends Component {
fetchedApiKey: false,
savedApiKey: '',
apiKey: '',
gmAuthFailure: false,
gmAuthFailure: ( typeof window.googlemaps_authfailure === 'undefined' ) ? false : !!window.googlemaps_authfailure,
}

this.onChangeMarkers = this.onChangeMarkers.bind( this );
Expand Down Expand Up @@ -124,6 +125,7 @@ class Edit extends Component {
const key = new wp.api.models.Settings( { [ API_KEY_SETTING_ID ]: apiKey } );

key.save().then(() => {
this.setState( { gmAuthFailure: false } );
this.settings.fetch();
} );
}
Expand Down Expand Up @@ -161,7 +163,7 @@ class Edit extends Component {

if ( gmAuthFailure ) {
return (
<Fragment>{ __( 'It seems that your Google Maps API key is INVALID. Please double check that you pasted it correctly and that it is a valid API key. More information about how to', '__plugin_txtd' ) } { hyperlink }</Fragment>
<Fragment>{ __( 'It seems that your Google Maps API key is INVALID. Please REFRESH the page, double check that you pasted it correctly, and that it is a valid API key. More information about how to', '__plugin_txtd' ) } { hyperlink }</Fragment>
)
}

Expand Down

0 comments on commit 708ed64

Please sign in to comment.