extract methods here
This commit is contained in:
parent
a4a7c23148
commit
061f44f475
1 changed files with 34 additions and 20 deletions
|
@ -64,17 +64,7 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
const relationEntry = entry.redactingEntry || entry;
|
const relationEntry = entry.redactingEntry || entry;
|
||||||
if (relationEntry.isRelatedToId(this.id)) {
|
if (relationEntry.isRelatedToId(this.id)) {
|
||||||
if (relationEntry.relation.rel_type === ANNOTATION_RELATION_TYPE) {
|
if (relationEntry.relation.rel_type === ANNOTATION_RELATION_TYPE) {
|
||||||
if (!this._pendingAnnotations) {
|
if (this._addPendingAnnotation(entry)) {
|
||||||
this._pendingAnnotations = new Map();
|
|
||||||
}
|
|
||||||
const {key} = (entry.redactingEntry || entry).relation;
|
|
||||||
if (key) {
|
|
||||||
let annotation = this._pendingAnnotations.get(key);
|
|
||||||
if (!annotation) {
|
|
||||||
annotation = new PendingAnnotation();
|
|
||||||
this._pendingAnnotations.set(key, annotation);
|
|
||||||
}
|
|
||||||
annotation.add(entry);
|
|
||||||
return "pendingAnnotations";
|
return "pendingAnnotations";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,6 +90,32 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
const relationEntry = entry.redactingEntry || entry;
|
const relationEntry = entry.redactingEntry || entry;
|
||||||
if (relationEntry.isRelatedToId(this.id)) {
|
if (relationEntry.isRelatedToId(this.id)) {
|
||||||
if (relationEntry.relation?.rel_type === ANNOTATION_RELATION_TYPE && this._pendingAnnotations) {
|
if (relationEntry.relation?.rel_type === ANNOTATION_RELATION_TYPE && this._pendingAnnotations) {
|
||||||
|
if (this._removePendingAnnotation(entry)) {
|
||||||
|
return "pendingAnnotations";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_addPendingAnnotation(entry) {
|
||||||
|
if (!this._pendingAnnotations) {
|
||||||
|
this._pendingAnnotations = new Map();
|
||||||
|
}
|
||||||
|
const {key} = (entry.redactingEntry || entry).relation;
|
||||||
|
if (key) {
|
||||||
|
let annotation = this._pendingAnnotations.get(key);
|
||||||
|
if (!annotation) {
|
||||||
|
annotation = new PendingAnnotation();
|
||||||
|
this._pendingAnnotations.set(key, annotation);
|
||||||
|
}
|
||||||
|
annotation.add(entry);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_removePendingAnnotation(entry) {
|
||||||
const {key} = (entry.redactingEntry || entry).relation;
|
const {key} = (entry.redactingEntry || entry).relation;
|
||||||
if (key) {
|
if (key) {
|
||||||
let annotation = this._pendingAnnotations.get(key);
|
let annotation = this._pendingAnnotations.get(key);
|
||||||
|
@ -109,11 +125,9 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
if (this._pendingAnnotations.size === 0) {
|
if (this._pendingAnnotations.size === 0) {
|
||||||
this._pendingAnnotations = null;
|
this._pendingAnnotations = null;
|
||||||
}
|
}
|
||||||
return "pendingAnnotations";
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async abortPendingRedaction() {
|
async abortPendingRedaction() {
|
||||||
|
|
Reference in a new issue