Skip to content

Commit

Permalink
update isEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Dec 12, 2023
1 parent 7481098 commit 865dfe3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/firestore/src/lite-api/user_data_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
FieldPath as PublicFieldPath,
SetOptions
} from '@firebase/firestore-types';
import { Compat, getModularInstance } from '@firebase/util';
import { Compat, deepEqual, getModularInstance } from '@firebase/util';

import { ParseContext } from '../api/parse_context';
import { DatabaseId } from '../core/database_info';
Expand Down Expand Up @@ -525,13 +525,15 @@ export class ArrayUnionFieldValueImpl extends FieldValue {
}

isEqual(other: FieldValue): boolean {
// TODO(mrschmidt): Implement isEquals
return this === other;
return (
other instanceof ArrayUnionFieldValueImpl &&
deepEqual(this._elements, other._elements)
);
}
}

export class ArrayRemoveFieldValueImpl extends FieldValue {
constructor(methodName: string, readonly _elements: unknown[]) {
constructor(methodName: string, private readonly _elements: unknown[]) {
super(methodName);
}

Expand All @@ -549,8 +551,10 @@ export class ArrayRemoveFieldValueImpl extends FieldValue {
}

isEqual(other: FieldValue): boolean {
// TODO(mrschmidt): Implement isEquals
return this === other;
return (
other instanceof ArrayRemoveFieldValueImpl &&
deepEqual(this._elements, other._elements)
);
}
}

Expand All @@ -568,8 +572,10 @@ export class NumericIncrementFieldValueImpl extends FieldValue {
}

isEqual(other: FieldValue): boolean {
// TODO(mrschmidt): Implement isEquals
return this === other;
return (
other instanceof NumericIncrementFieldValueImpl &&
this._operand === other._operand
);
}
}

Expand Down

0 comments on commit 865dfe3

Please sign in to comment.