fix local redaction echo while already sending target
This commit is contained in:
parent
a77ef02677
commit
cad884aa41
2 changed files with 10 additions and 9 deletions
|
@ -52,7 +52,7 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
@return [string] returns the name of the field that has changed, if any
|
@return [string] returns the name of the field that has changed, if any
|
||||||
*/
|
*/
|
||||||
addLocalRelation(entry) {
|
addLocalRelation(entry) {
|
||||||
if (entry.eventType === REDACTION_TYPE && entry.relatedEventId === this.id) {
|
if (entry.eventType === REDACTION_TYPE && entry.isRelatedToId(this.id)) {
|
||||||
if (!this._pendingRedactions) {
|
if (!this._pendingRedactions) {
|
||||||
this._pendingRedactions = [];
|
this._pendingRedactions = [];
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const relationEntry = entry.redactingEntry || entry;
|
const relationEntry = entry.redactingEntry || entry;
|
||||||
if (relationEntry.isRelationForId(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._pendingAnnotations) {
|
||||||
this._pendingAnnotations = new PendingAnnotations();
|
this._pendingAnnotations = new PendingAnnotations();
|
||||||
|
@ -79,7 +79,7 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
@return [string] returns the name of the field that has changed, if any
|
@return [string] returns the name of the field that has changed, if any
|
||||||
*/
|
*/
|
||||||
removeLocalRelation(entry) {
|
removeLocalRelation(entry) {
|
||||||
if (entry.eventType === REDACTION_TYPE && entry.relatedEventId === this.id && this._pendingRedactions) {
|
if (entry.eventType === REDACTION_TYPE && entry.isRelatedToId(this.id) && this._pendingRedactions) {
|
||||||
const countBefore = this._pendingRedactions.length;
|
const countBefore = this._pendingRedactions.length;
|
||||||
this._pendingRedactions = this._pendingRedactions.filter(e => e !== entry);
|
this._pendingRedactions = this._pendingRedactions.filter(e => e !== entry);
|
||||||
if (this._pendingRedactions.length === 0) {
|
if (this._pendingRedactions.length === 0) {
|
||||||
|
@ -90,8 +90,8 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const relationEntry = entry.redactingEntry || entry;
|
const relationEntry = entry.redactingEntry || entry;
|
||||||
if (relationEntry.isRelationForId(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) {
|
||||||
this._pendingAnnotations.remove(entry);
|
this._pendingAnnotations.remove(entry);
|
||||||
if (this._pendingAnnotations.isEmpty) {
|
if (this._pendingAnnotations.isEmpty) {
|
||||||
this._pendingAnnotations = null;
|
this._pendingAnnotations = null;
|
||||||
|
@ -123,8 +123,9 @@ export class BaseEventEntry extends BaseEntry {
|
||||||
return createAnnotation(this.id, key);
|
return createAnnotation(this.id, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
isRelationForId(id) {
|
/** takes both remote event id and local txn id into account, see overriding in PendingEventEntry */
|
||||||
return id && this.relation?.event_id === id;
|
isRelatedToId(id) {
|
||||||
|
return id && this.relatedEventId === id;
|
||||||
}
|
}
|
||||||
|
|
||||||
get relation() {
|
get relation() {
|
||||||
|
|
|
@ -83,11 +83,11 @@ export class PendingEventEntry extends BaseEventEntry {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isRelationForId(id) {
|
isRelatedToId(id) {
|
||||||
if (id && id === this._pendingEvent.relatedTxnId) {
|
if (id && id === this._pendingEvent.relatedTxnId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.isRelationForId(id);
|
return super.isRelatedToId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
get relatedEventId() {
|
get relatedEventId() {
|
||||||
|
|
Reference in a new issue