Merge pull request #1780 from realm/tg/seen-realms-tracking

Track Realms seen in the notifier by id rather than path
This commit is contained in:
Kenneth Geisshirt 2018-05-07 13:18:52 +02:00 committed by GitHub
commit b703c1f069
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,11 +45,11 @@ class FunctionListener {
return this.regexStr === regex && this.event === event && this.fn === fn;
}
onavailable(path) {
onavailable(path, id) {
if (this.regex.test(path)) {
if (this.event === 'available' && !this.seen[path]) {
if (this.event === 'available' && !this.seen[id]) {
this.fn(path);
this.seen[path] = true;
this.seen[id] = true;
}
return this.event === 'change';
}
@ -103,11 +103,11 @@ class OutOfProcListener {
return this.regexStr === regex && this.worker === worker;
}
onavailable(path) {
onavailable(path, id) {
if (this.regex.test(path)) {
if (!this.seen[path]) {
if (!this.seen[id]) {
this.worker.onavailable(path);
this.seen[path] = true;
this.seen[id] = true;
}
return true;
}
@ -161,10 +161,11 @@ class Listener {
changes.release();
}
available(virtualPath) {
available(virtualPath, id) {
let watch = false;
id = id || virtualPath;
for (const callback of this.callbacks) {
if (callback.onavailable(virtualPath)) {
if (callback.onavailable(virtualPath, id)) {
watch = true;
}
}