Bug fixes and buttons for previous and next page

* Use buttons for next and previous page in search results
* Add custom routine for stringifying and parsing the selector to JSON
so RegExp objects are preserved
This commit is contained in:
John R. Supplee 2021-01-27 16:15:54 +02:00
parent 4e8fc46475
commit 78a1d08a17
6 changed files with 74 additions and 15 deletions

View file

@ -126,6 +126,40 @@ SessionData.attachSchema(
}),
);
SessionData.helpers({
getSelector() {
return SessionData.unpickle(this.selector);
},
});
SessionData.unpickle = pickle => {
return JSON.parse(pickle, (key, value) => {
if (typeof value === 'object') {
if (value.hasOwnProperty('$$class')) {
if (value.$$class === 'RegExp') {
return new RegExp(value.source, value.flags);
}
}
}
return value;
});
};
SessionData.pickle = value => {
return JSON.stringify(value, (key, value) => {
if (typeof value === 'object') {
if (value.constructor.name === 'RegExp') {
return {
$$class: 'RegExp',
source: value.source,
flags: value.flags,
};
}
}
return value;
});
};
if (!Meteor.isServer) {
SessionData.getSessionId = () => {
let sessionId = Session.get('sessionId');