Supporting patterns in classNames for Live Queries (#7131)

* Parse LiveQuery Server. Supporting patterns in classNames.

* Parse LiveQuery Server. Supporting patterns in classNames. Small optimisation.

* Parse LiveQuery Server. Supporting patterns in classNames. Adding info to changelog.

* Parse LiveQuery Server. Supporting patterns in classNames. Test case.
This commit is contained in:
Nikita
2021-01-20 01:19:11 +03:00
committed by GitHub
parent 034ea5c828
commit e592212b97
3 changed files with 33 additions and 2 deletions

View File

@@ -9,7 +9,9 @@ export class LiveQueryController {
if (!config || !config.classNames) {
this.classNames = new Set();
} else if (config.classNames instanceof Array) {
this.classNames = new Set(config.classNames);
const classNames = config.classNames
.map(name => new RegExp("^" + name + "$"));
this.classNames = new Set(classNames);
} else {
throw 'liveQuery.classes should be an array of string';
}
@@ -43,7 +45,12 @@ export class LiveQueryController {
}
hasLiveQuery(className: string): boolean {
return this.classNames.has(className);
for (const name of this.classNames) {
if (name.test(className)) {
return true;
}
}
return false;
}
_makePublisherRequest(currentObject: any, originalObject: any, classLevelPermissions: ?any): any {