meteor3: purge dead client packages — web UI renders on 3.1
alanning:roles removed (client crashed the whole bundle; plain user.roles checks instead), selaias:cookie-consent replaced by in-repo React banner, publish-performant-counts vendored with countAsync, Meteor.autorun dropped (App)/Tracker.autorun (FiresMap), and the map publications not covered by the REST smoke (activefiresmyloc, activefiresunionmyloc, fireAlerts, oauth.verifyConfiguration) converted to async APIs. Verified in browser: / and /fires render with map + cookie banner, zero uncaught exceptions. REST smoke byte-identical (12/12).
This commit is contained in:
parent
0ff9848cd4
commit
eb3aec82ae
16 changed files with 194 additions and 50 deletions
|
|
@ -16,7 +16,6 @@ ecmascript@0.16.10 # Enable ECMAScript2015+ syntax in app code
|
||||||
shell-server@0.6.1 # Server-side component of the `meteor shell` command
|
shell-server@0.6.1 # Server-side component of the `meteor shell` command
|
||||||
|
|
||||||
react-meteor-data
|
react-meteor-data
|
||||||
alanning:roles
|
|
||||||
fourseven:scss@5.0.0
|
fourseven:scss@5.0.0
|
||||||
accounts-base@3.0.3
|
accounts-base@3.0.3
|
||||||
accounts-password@3.0.3
|
accounts-password@3.0.3
|
||||||
|
|
@ -33,14 +32,13 @@ dynamic-import@0.7.4
|
||||||
static-html@1.4.0
|
static-html@1.4.0
|
||||||
alexwine:bootstrap-4
|
alexwine:bootstrap-4
|
||||||
|
|
||||||
selaias:cookie-consent # Cookie consent
|
|
||||||
gadicc:blaze-react-component # Add braze to react
|
gadicc:blaze-react-component # Add braze to react
|
||||||
255kb:meteor-status # Connect status
|
255kb:meteor-status # Connect status
|
||||||
# mixmax:smart-disconnect # Disconnect on lost focus (disabled to get notif)
|
# mixmax:smart-disconnect # Disconnect on lost focus (disabled to get notif)
|
||||||
flowkey:raven # js errors
|
flowkey:raven # js errors
|
||||||
vjrj:piwik # Stats
|
vjrj:piwik # Stats
|
||||||
mdg:geolocation
|
mdg:geolocation
|
||||||
natestrauser:publish-performant-counts
|
tcef:publish-performant-counts
|
||||||
ostrio:mailer # mailer
|
ostrio:mailer # mailer
|
||||||
# babrahams:constellation # dev utility
|
# babrahams:constellation # dev utility
|
||||||
percolate:migrations # db migrations
|
percolate:migrations # db migrations
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ accounts-github@1.5.1
|
||||||
accounts-google@1.4.1
|
accounts-google@1.4.1
|
||||||
accounts-oauth@1.4.5
|
accounts-oauth@1.4.5
|
||||||
accounts-password@3.0.3
|
accounts-password@3.0.3
|
||||||
alanning:roles@1.2.10
|
|
||||||
aldeed:collection2@4.2.0
|
aldeed:collection2@4.2.0
|
||||||
aldeed:schema-deny@4.0.2
|
aldeed:schema-deny@4.0.2
|
||||||
aldeed:simple-schema@1.13.1
|
aldeed:simple-schema@1.13.1
|
||||||
|
|
@ -75,7 +74,6 @@ mongo-decimal@0.2.0
|
||||||
mongo-dev-server@1.1.1
|
mongo-dev-server@1.1.1
|
||||||
mongo-id@1.0.9
|
mongo-id@1.0.9
|
||||||
mongo-livedata@1.0.13
|
mongo-livedata@1.0.13
|
||||||
natestrauser:publish-performant-counts@0.1.2
|
|
||||||
nimble:restivus@0.8.12
|
nimble:restivus@0.8.12
|
||||||
npm-mongo@6.10.0
|
npm-mongo@6.10.0
|
||||||
nspangler:autoreconnect@0.0.1
|
nspangler:autoreconnect@0.0.1
|
||||||
|
|
@ -83,7 +81,6 @@ oauth@3.0.0
|
||||||
oauth2@1.3.3
|
oauth2@1.3.3
|
||||||
observe-sequence@2.0.1
|
observe-sequence@2.0.1
|
||||||
ordered-dict@1.2.0
|
ordered-dict@1.2.0
|
||||||
ostrio:cookies@2.8.0
|
|
||||||
ostrio:mailer@2.5.0
|
ostrio:mailer@2.5.0
|
||||||
ostrio:meteor-root@1.0.7
|
ostrio:meteor-root@1.0.7
|
||||||
percolate:migrations@2.0.1
|
percolate:migrations@2.0.1
|
||||||
|
|
@ -99,7 +96,6 @@ reload@1.3.2
|
||||||
retry@1.1.1
|
retry@1.1.1
|
||||||
reywood:publish-composite@1.6.0
|
reywood:publish-composite@1.6.0
|
||||||
routepolicy@1.1.2
|
routepolicy@1.1.2
|
||||||
selaias:cookie-consent@0.4.0
|
|
||||||
service-configuration@1.3.5
|
service-configuration@1.3.5
|
||||||
sha@1.0.10
|
sha@1.0.10
|
||||||
shell-server@0.6.1
|
shell-server@0.6.1
|
||||||
|
|
@ -111,6 +107,7 @@ standard-minifier-css@1.9.3
|
||||||
standard-minifier-js@3.0.0
|
standard-minifier-js@3.0.0
|
||||||
static-html@1.4.0
|
static-html@1.4.0
|
||||||
static-html-tools@1.0.0
|
static-html-tools@1.0.0
|
||||||
|
tcef:publish-performant-counts@0.2.0
|
||||||
templating@1.4.4
|
templating@1.4.4
|
||||||
templating-compiler@2.0.1
|
templating-compiler@2.0.1
|
||||||
templating-runtime@2.0.2
|
templating-runtime@2.0.2
|
||||||
|
|
|
||||||
25
UPGRADE.md
25
UPGRADE.md
|
|
@ -251,6 +251,31 @@ MONGO_CONTAINER=tcef-mongo7 MONGO_SHELL=mongosh MONGO_PORT=27019 ./smoke/smoke.s
|
||||||
`WebApp.connectHandlers` handler serving the same static page list (the
|
`WebApp.connectHandlers` handler serving the same static page list (the
|
||||||
per-fire section of the old handler was behind `firesMapEnabled = false`,
|
per-fire section of the old handler was behind `firesMapEnabled = false`,
|
||||||
i.e. dead code, and was dropped). Verified serving on dev.
|
i.e. dead code, and was dropped). Verified serving on dev.
|
||||||
|
- ✅ **Dead client packages purged — the web UI now RENDERS on Meteor 3.**
|
||||||
|
First-ever browser verification of this branch (the smoke only covers REST)
|
||||||
|
found a chain of ancient Blaze-era packages whose client code threw at
|
||||||
|
bundle load, killing the whole app (`meteorInstall is not defined`):
|
||||||
|
- **alanning:roles 1.2.10** (client crash, and its server
|
||||||
|
`Roles.userIsInRole` is sync) → package removed; the app barely used it:
|
||||||
|
`facts.js` now checks the plain `user.roles` field (admin set cached at
|
||||||
|
startup) and App.js takes `roles` from the user doc (prop was unused).
|
||||||
|
Upgrading to roles v4 was rejected: needs a prod data migration.
|
||||||
|
- **selaias:cookie-consent** (its `Cookies` global is gone) → removed;
|
||||||
|
replaced by in-repo React `imports/ui/components/CookieConsent` reusing
|
||||||
|
the same i18n keys; `CookieConsent.init` dropped from `i18n.js`.
|
||||||
|
- **natestrauser:publish-performant-counts** server `Counter._publishCursor`
|
||||||
|
uses sync `cursor.count()` → **vendored** as
|
||||||
|
`packages/publish-performant-counts` (`tcef:publish-performant-counts`)
|
||||||
|
with `countAsync` and an async-aware interval; same public API.
|
||||||
|
- `Meteor.autorun` (removed in Meteor 3) → dropped (App.js debug) /
|
||||||
|
`Tracker.autorun` (FiresMap).
|
||||||
|
- Map/server publications not exercised by the REST smoke converted to
|
||||||
|
async: `activefiresmyloc`, `activefiresunionmyloc`, `fireAlerts`
|
||||||
|
(countAsync/fetchAsync/awaited firesUnion), and `oauth.verifyConfiguration`
|
||||||
|
(findOneAsync). `migrations.js` bodies stay sync **by design** (control is
|
||||||
|
pinned at v18; prod data arrives pre-migrated) — tracked as debt.
|
||||||
|
Verified in a real browser: `/` and `/fires` render (map, search, layers,
|
||||||
|
cookie banner), zero uncaught exceptions; REST smoke byte-identical.
|
||||||
|
|
||||||
### Still TODO before the web (not just REST) is fully deployable on 3.x
|
### Still TODO before the web (not just REST) is fully deployable on 3.x
|
||||||
- **React 16 → 18** render root + verify ancient react-* libs.
|
- **React 16 → 18** render root + verify ancient react-* libs.
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Meteor.publish('activefirestotal', function total() {
|
||||||
return counter;
|
return counter;
|
||||||
});
|
});
|
||||||
|
|
||||||
const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
|
const activefires = async (northEastLng, northEastLat, southWestLng, southWestLat, withMarks) => {
|
||||||
const fires = ActiveFires.find({
|
const fires = ActiveFires.find({
|
||||||
ourid: {
|
ourid: {
|
||||||
$geoWithin: {
|
$geoWithin: {
|
||||||
|
|
@ -36,10 +36,10 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isDevelopment) console.log(`Active fires total: ${fires.count()}`);
|
if (Meteor.isDevelopment) console.log(`Active fires total: ${await fires.countAsync()}`);
|
||||||
|
|
||||||
if (withMarks && fires.fetch().length > 0) {
|
if (withMarks && (await fires.fetchAsync()).length > 0) {
|
||||||
const union = firesUnion(fires);
|
const union = await firesUnion(fires);
|
||||||
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
||||||
const industries = whichAreFalsePositives(Industries, union);
|
const industries = whichAreFalsePositives(Industries, union);
|
||||||
return [fires, falsePos, industries];
|
return [fires, falsePos, industries];
|
||||||
|
|
@ -48,7 +48,7 @@ const activefires = (northEastLng, northEastLat, southWestLng, southWestLat, wit
|
||||||
return fires;
|
return fires;
|
||||||
};
|
};
|
||||||
|
|
||||||
Meteor.publish('activefiresmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
Meteor.publish('activefiresmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||||
// latitude -90 and 90 and the longitude between -180 and 180
|
// latitude -90 and 90 and the longitude between -180 and 180
|
||||||
check(northEastLng, NumberBetween(-180, 180));
|
check(northEastLng, NumberBetween(-180, 180));
|
||||||
check(southWestLat, NumberBetween(-90, 90));
|
check(southWestLat, NumberBetween(-90, 90));
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Meteor.publish('activefiresuniontotal', function total() {
|
||||||
return counter;
|
return counter;
|
||||||
});
|
});
|
||||||
|
|
||||||
const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
const activeFiresUnion = async (b1, b2, c1, c2, withMarks) => {
|
||||||
// a --- b
|
// a --- b
|
||||||
// c --- d
|
// c --- d
|
||||||
const geometry = {
|
const geometry = {
|
||||||
|
|
@ -46,7 +46,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isDevelopment) console.log(`Active fires union total: ${fires.count()}`);
|
if (Meteor.isDevelopment) console.log(`Active fires union total: ${await fires.countAsync()}`);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (withMarks && fires.fetch().length > 0) {
|
if (withMarks && fires.fetch().length > 0) {
|
||||||
|
|
@ -59,7 +59,7 @@ const activeFiresUnion = (b1, b2, c1, c2, withMarks) => {
|
||||||
return fires;
|
return fires;
|
||||||
};
|
};
|
||||||
|
|
||||||
Meteor.publish('activefiresunionmyloc', function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
Meteor.publish('activefiresunionmyloc', async function activeInMyLoc(northEastLng, northEastLat, southWestLng, southWestLat, withMarks) {
|
||||||
// latitude -90 and 90 and the longitude between -180 and 180
|
// latitude -90 and 90 and the longitude between -180 and 180
|
||||||
check(northEastLng, NumberBetween(-180, 180));
|
check(northEastLng, NumberBetween(-180, 180));
|
||||||
check(southWestLat, NumberBetween(-90, 90));
|
check(southWestLat, NumberBetween(-90, 90));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { check } from 'meteor/check';
|
||||||
import { NumberBetween } from '/imports/modules/server/other-checks';
|
import { NumberBetween } from '/imports/modules/server/other-checks';
|
||||||
import FireAlerts from '../FireAlerts';
|
import FireAlerts from '../FireAlerts';
|
||||||
|
|
||||||
Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, southWestLng, southWestLat) {
|
Meteor.publish('fireAlerts', async function fireAlerts(northEastLng, northEastLat, southWestLng, southWestLat) {
|
||||||
// latitude -90 and 90 and the longitude between -180 and 180
|
// latitude -90 and 90 and the longitude between -180 and 180
|
||||||
check(northEastLng, NumberBetween(-180, 180));
|
check(northEastLng, NumberBetween(-180, 180));
|
||||||
check(southWestLat, NumberBetween(-90, 90));
|
check(southWestLat, NumberBetween(-90, 90));
|
||||||
|
|
@ -37,6 +37,6 @@ Meteor.publish('fireAlerts', function fireAlerts(northEastLng, northEastLat, sou
|
||||||
track: 1
|
track: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${fires.count()}`);
|
if (Meteor.isDevelopment) console.log(`Neighbour alerts total: ${await fires.countAsync()}`);
|
||||||
return fires;
|
return fires;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@ import { ServiceConfiguration } from 'meteor/service-configuration';
|
||||||
import rateLimit from '../../../modules/rate-limit';
|
import rateLimit from '../../../modules/rate-limit';
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
'oauth.verifyConfiguration': function oauthVerifyConfiguration(services) {
|
'oauth.verifyConfiguration': async function oauthVerifyConfiguration(services) {
|
||||||
check(services, Array);
|
check(services, Array);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const verifiedServices = [];
|
const verifiedServices = [];
|
||||||
services.forEach((service) => {
|
for (const service of services) {
|
||||||
if (ServiceConfiguration.configurations.findOne({ service })) {
|
if (await ServiceConfiguration.configurations.findOneAsync({ service })) {
|
||||||
verifiedServices.push(service);
|
verifiedServices.push(service);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return verifiedServices.sort();
|
return verifiedServices.sort();
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
throw new Meteor.Error('500', exception);
|
throw new Meteor.Error('500', exception);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* global CookieConsent Intl */
|
/* global Intl */
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Tracker } from 'meteor/tracker';
|
import { Tracker } from 'meteor/tracker';
|
||||||
|
|
@ -89,23 +89,9 @@ i18n.use(backend)
|
||||||
|
|
||||||
i18nReady.set(true);
|
i18nReady.set(true);
|
||||||
|
|
||||||
// cookies eu consent
|
// Cookie consent banner: selaias:cookie-consent (Blaze, dead on Meteor 3)
|
||||||
const cookiesOpt = {
|
// replaced by the React component imports/ui/components/CookieConsent,
|
||||||
cookieTitle: t('Uso de Cookies'),
|
// which reuses the same i18n keys.
|
||||||
cookieMessage: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'),
|
|
||||||
/* cookieMessage: t('Uso de Cookies'),
|
|
||||||
cookieMessageImply: t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso'), */
|
|
||||||
showLink: false,
|
|
||||||
position: 'bottom',
|
|
||||||
linkText: 'Lee más',
|
|
||||||
linkRouteName: '/privacy',
|
|
||||||
acceptButtonText: t('Aceptar'),
|
|
||||||
html: false,
|
|
||||||
expirationInDays: 70,
|
|
||||||
forceShow: false
|
|
||||||
};
|
|
||||||
|
|
||||||
CookieConsent.init(cookiesOpt);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.subscribe('userData'); // lang is there
|
Meteor.subscribe('userData'); // lang is there
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
/* global Facts */
|
|
||||||
import { Roles } from 'meteor/alanning:roles';
|
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
import { Facts } from 'meteor/facts-base';
|
||||||
|
|
||||||
Facts.setUserIdFilter(userId => Roles.userIsInRole(userId, ['admin']));
|
/*
|
||||||
|
* alanning:roles removed (1.x is dead on Meteor 3 — crashes the whole client
|
||||||
|
* bundle at load — and 4.x needs a data migration we don't want). Admin check
|
||||||
|
* against the plain `user.roles` field, cached at startup: facts are
|
||||||
|
* dev/admin instrumentation and the admin set essentially never changes.
|
||||||
|
*/
|
||||||
|
const adminIds = new Set();
|
||||||
|
|
||||||
|
Meteor.startup(async () => {
|
||||||
|
await Meteor.users
|
||||||
|
.find({ roles: 'admin' }, { fields: { _id: 1 } })
|
||||||
|
.forEachAsync(u => adminIds.add(u._id));
|
||||||
|
});
|
||||||
|
|
||||||
|
Facts.setUserIdFilter(userId => adminIds.has(userId));
|
||||||
|
|
|
||||||
45
imports/ui/components/CookieConsent/CookieConsent.js
Normal file
45
imports/ui/components/CookieConsent/CookieConsent.js
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import i18n from 'i18next';
|
||||||
|
import './CookieConsent.scss';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Minimal cookie-consent banner replacing selaias:cookie-consent (Blaze,
|
||||||
|
* dead on Meteor 3: its `Cookies` global is gone and it crashed the whole
|
||||||
|
* client bundle at load). Same behavior: informative banner, dismissed once.
|
||||||
|
*/
|
||||||
|
const STORAGE_KEY = 'tcef-cookie-consent';
|
||||||
|
|
||||||
|
class CookieConsent extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
let accepted = false;
|
||||||
|
try {
|
||||||
|
accepted = window.localStorage.getItem(STORAGE_KEY) === 'yes';
|
||||||
|
} catch (e) { /* storage disabled: show banner every time */ }
|
||||||
|
this.state = { accepted };
|
||||||
|
this.accept = this.accept.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
accept() {
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(STORAGE_KEY, 'yes');
|
||||||
|
} catch (e) { /* ignore */ }
|
||||||
|
this.setState({ accepted: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.accepted) return null;
|
||||||
|
return (
|
||||||
|
<div className="CookieConsent">
|
||||||
|
<span>
|
||||||
|
{i18n.t('Utilizamos cookies para asegurar un mejor uso de nuestra web. Si continúas navegando, consideramos que aceptas su uso')}
|
||||||
|
</span>
|
||||||
|
<button type="button" className="btn btn-primary btn-sm" onClick={this.accept}>
|
||||||
|
{i18n.t('Aceptar')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CookieConsent;
|
||||||
20
imports/ui/components/CookieConsent/CookieConsent.scss
Normal file
20
imports/ui/components/CookieConsent/CookieConsent.scss
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
.CookieConsent {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 2000;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1em;
|
||||||
|
padding: 0.75em 1em;
|
||||||
|
background: rgba(0, 0, 0, 0.85);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.9em;
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-left: 1em;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,6 @@ import { I18nextProvider } from 'react-i18next';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
import { Roles } from 'meteor/alanning:roles';
|
|
||||||
// https://github.com/gadicc/meteor-blaze-react-component/
|
// https://github.com/gadicc/meteor-blaze-react-component/
|
||||||
import Blaze from 'meteor/gadicc:blaze-react-component';
|
import Blaze from 'meteor/gadicc:blaze-react-component';
|
||||||
// i18n
|
// i18n
|
||||||
|
|
@ -48,6 +47,7 @@ import About from '../../pages/About/About';
|
||||||
import Privacy from '../../pages/Privacy/Privacy';
|
import Privacy from '../../pages/Privacy/Privacy';
|
||||||
import License from '../../pages/License/License';
|
import License from '../../pages/License/License';
|
||||||
import Credits from '../../pages/Credits/Credits';
|
import Credits from '../../pages/Credits/Credits';
|
||||||
|
import CookieConsent from '../../components/CookieConsent/CookieConsent';
|
||||||
import Footer from '../../components/Footer/Footer';
|
import Footer from '../../components/Footer/Footer';
|
||||||
import Feedback from '../../components/Feedback/Feedback';
|
import Feedback from '../../components/Feedback/Feedback';
|
||||||
import ReSendEmail from '../../components/ReSendEmail/ReSendEmail';
|
import ReSendEmail from '../../components/ReSendEmail/ReSendEmail';
|
||||||
|
|
@ -151,7 +151,7 @@ const App = props => (
|
||||||
<Footer />
|
<Footer />
|
||||||
<Reconnect {...props} />
|
<Reconnect {...props} />
|
||||||
<Feedback {...props} />
|
<Feedback {...props} />
|
||||||
{props.i18nReady.get() && <Blaze template="cookieConsent" /> }
|
{props.i18nReady.get() && <CookieConsent /> }
|
||||||
</div>}
|
</div>}
|
||||||
</LocationListener>
|
</LocationListener>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
@ -183,19 +183,16 @@ export default withTracker(() => {
|
||||||
const loggingIn = Meteor.loggingIn();
|
const loggingIn = Meteor.loggingIn();
|
||||||
const user = Meteor.user();
|
const user = Meteor.user();
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
const loading = !Roles.subscription.ready() || !i18nReady.get();
|
const loading = !i18nReady.get();
|
||||||
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
|
const name = user && user.profile && user.profile.name && getUserName(user.profile.name);
|
||||||
const emailAddress = user && user.emails && user.emails[0].address;
|
const emailAddress = user && user.emails && user.emails[0].address;
|
||||||
Meteor.autorun(() => {
|
|
||||||
console.log(`i18n ready?: ${i18nReady.get()}`);
|
|
||||||
});
|
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
loggingIn,
|
loggingIn,
|
||||||
i18nReady,
|
i18nReady,
|
||||||
authenticated: !loggingIn && !!userId,
|
authenticated: !loggingIn && !!userId,
|
||||||
name: name || emailAddress,
|
name: name || emailAddress,
|
||||||
roles: !loading && Roles.getRolesForUser(userId),
|
roles: (user && user.roles) || [],
|
||||||
userId,
|
userId,
|
||||||
emailAddress,
|
emailAddress,
|
||||||
emailVerified: user && user.emails ? user && user.emails && user.emails[0].verified : true
|
emailVerified: user && user.emails ? user && user.emails && user.emails[0].verified : true
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { ButtonGroup, Row, Col, Checkbox } from 'react-bootstrap';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { ReactiveVar } from 'meteor/reactive-var';
|
import { ReactiveVar } from 'meteor/reactive-var';
|
||||||
import { withTracker } from 'meteor/react-meteor-data';
|
import { withTracker } from 'meteor/react-meteor-data';
|
||||||
|
import { Tracker } from 'meteor/tracker';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { Trans, translate } from 'react-i18next';
|
import { Trans, translate } from 'react-i18next';
|
||||||
import { Map } from 'react-leaflet';
|
import { Map } from 'react-leaflet';
|
||||||
|
|
@ -408,7 +409,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
||||||
}
|
}
|
||||||
// Disable, because this increase the number of fires by one
|
// Disable, because this increase the number of fires by one
|
||||||
// Meteor.subscribe('lastFireDetected');
|
// Meteor.subscribe('lastFireDetected');
|
||||||
Meteor.autorun(() => {
|
Tracker.autorun(() => {
|
||||||
if ((centerStored !== [0, 0] || geolocation.get()) && geoInit) {
|
if ((centerStored !== [0, 0] || geolocation.get()) && geoInit) {
|
||||||
center.set(centerStored || geolocation.get());
|
center.set(centerStored || geolocation.get());
|
||||||
// console.log(`Geolocation ${geolocation.get()}`);
|
// console.log(`Geolocation ${geolocation.get()}`);
|
||||||
|
|
|
||||||
9
packages/publish-performant-counts/client.js
Normal file
9
packages/publish-performant-counts/client.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* global Counter:true */
|
||||||
|
|
||||||
|
Counter = {};
|
||||||
|
Counter.collection = new Mongo.Collection('counters-collection');
|
||||||
|
|
||||||
|
Counter.get = function (name) {
|
||||||
|
const doc = Counter.collection.findOne(name);
|
||||||
|
return doc ? doc.count : 0;
|
||||||
|
};
|
||||||
16
packages/publish-performant-counts/package.js
Normal file
16
packages/publish-performant-counts/package.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Vendored natestrauser:publish-performant-counts 0.1.2, patched for Meteor 3
|
||||||
|
// (server cursor.count() is gone -> countAsync). Same public API: server
|
||||||
|
// `new Counter(name, cursor)`, client `Counter.get(name)`.
|
||||||
|
Package.describe({
|
||||||
|
name: 'tcef:publish-performant-counts',
|
||||||
|
version: '0.2.0',
|
||||||
|
summary: 'Vendored publish-performant-counts patched for Meteor 3 (countAsync)'
|
||||||
|
});
|
||||||
|
|
||||||
|
Package.onUse(function (api) {
|
||||||
|
api.versionsFrom('3.0');
|
||||||
|
api.use(['meteor', 'mongo', 'ecmascript']);
|
||||||
|
api.addFiles('server.js', 'server');
|
||||||
|
api.addFiles('client.js', 'client');
|
||||||
|
api.export('Counter');
|
||||||
|
});
|
||||||
37
packages/publish-performant-counts/server.js
Normal file
37
packages/publish-performant-counts/server.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* global Counter:true */
|
||||||
|
|
||||||
|
Counter = function (name, cursor, interval) {
|
||||||
|
this.name = name;
|
||||||
|
this.cursor = cursor;
|
||||||
|
this.interval = interval || 1000 * 10;
|
||||||
|
this._collectionName = 'counters-collection';
|
||||||
|
};
|
||||||
|
|
||||||
|
// every cursor must provide a collection name via this method
|
||||||
|
Counter.prototype._getCollectionName = function () {
|
||||||
|
return `counter-${this.name}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// the api to publish (async: Meteor 3 awaits _publishCursor)
|
||||||
|
Counter.prototype._publishCursor = async function (sub) {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
sub.added(self._collectionName, self.name, { count: await self.cursor.countAsync() });
|
||||||
|
|
||||||
|
const handler = Meteor.setInterval(async () => {
|
||||||
|
try {
|
||||||
|
const count = await self.cursor.countAsync();
|
||||||
|
sub.changed(self._collectionName, self.name, { count });
|
||||||
|
} catch (e) {
|
||||||
|
// transient db error: retry on the next tick
|
||||||
|
}
|
||||||
|
}, this.interval);
|
||||||
|
|
||||||
|
sub.onStop(() => {
|
||||||
|
Meteor.clearInterval(handler);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
stop: sub.onStop.bind(sub)
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue