Add live data updates for corpus follower lists

This commit is contained in:
Patrick Jentsch
2023-02-21 13:59:11 +01:00
parent ff238cd823
commit d699fd09e5
2 changed files with 69 additions and 9 deletions

View File

@ -169,5 +169,36 @@ class CorpusFollowerList extends ResourceList {
}
}
onPatch(patch) {}
onPatch(patch) {
let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)`);
let filteredPatch = patch.filter(operation => re.test(operation.path));
for (let operation of filteredPatch) {
switch(operation.op) {
case 'add': {
// let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)$`);
// if (re.test(operation.path)) {this.add(operation.value);}
break;
}
case 'remove': {
let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)$`);
if (re.test(operation.path)) {
let [match, jobId] = operation.path.match(re);
this.remove(jobId);
}
break;
}
case 'replace': {
// let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)/(service|status|description|title)$`);
// if (re.test(operation.path)) {
// let [match, jobId, valueName] = operation.path.match(re);
// this.replace(jobId, valueName, operation.value);
// }
break;
}
default: {
break;
}
}
}
}
}