fix(client): render the map pages when no Google Maps key is configured
Gkeys waited on the key VALUE to decide the script had loaded. With an empty gmaps key (any deployment that has not got one, and settings-ci.json) the ReactiveVar stayed falsy forever, so every component mounting after the script had already loaded — i.e. anything reached by client-side navigation — sat on "Waiting for the gkey" and rendered an empty <div>. /subscriptions/new was completely blank, with no error in the console: you simply could not add a zone. Tracking "loaded" separately from the key fixes it. Found while writing the e2e suite, which could not get past the add-zone page.
This commit is contained in:
parent
a3f2929ff7
commit
19b76a570c
1 changed files with 12 additions and 6 deletions
|
|
@ -6,6 +6,13 @@ import GoogleMapsLoader from 'google-maps';
|
|||
class GkeysC {
|
||||
constructor() {
|
||||
this.gmapkey = new ReactiveVar(null);
|
||||
// Separate from the key itself: a deployment with no gmaps key configured
|
||||
// still loads the script and still has to render. Waiting on the key value
|
||||
// meant that with an empty key every component mounted after the script had
|
||||
// loaded (i.e. any client-side navigation) sat forever on "Waiting for the
|
||||
// gkey" and rendered an empty <div> — /subscriptions/new was blank, with no
|
||||
// error anywhere.
|
||||
this.loaded = new ReactiveVar(false);
|
||||
const self = this;
|
||||
this.callbacks = [];
|
||||
Meteor.startup(() => {
|
||||
|
|
@ -20,6 +27,7 @@ class GkeysC {
|
|||
GoogleMapsLoader.createUrl = () => `${origCreateUrl()}&loading=async`;
|
||||
GoogleMapsLoader.load(() => {
|
||||
self.gmapkey.set(key);
|
||||
self.loaded.set(true);
|
||||
console.log('GMaps script just loaded');
|
||||
self.doCallbacks(key);
|
||||
});
|
||||
|
|
@ -37,14 +45,12 @@ class GkeysC {
|
|||
load(callback) {
|
||||
this.callbacks.push(callback);
|
||||
Tracker.autorun((computation) => {
|
||||
const key = this.gmapkey.get();
|
||||
if (key) {
|
||||
// already loaded
|
||||
// console.log('GMaps already loaded');
|
||||
this.doCallbacks(key);
|
||||
if (this.loaded.get()) {
|
||||
// already loaded; the key may legitimately be empty
|
||||
this.doCallbacks(this.gmapkey.get());
|
||||
computation.stop();
|
||||
} else {
|
||||
console.log('Waiting for the gkey');
|
||||
console.log('Waiting for the gmaps script');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue