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