Use proxy-compare for message bubbles
This commit is contained in:
parent
f92f81dfd6
commit
55a1c5f6c5
11 changed files with 442 additions and 562 deletions
|
@ -1,17 +1,31 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function isShallowEqual<Obj extends Record<string, unknown>>(
|
||||
a: Obj,
|
||||
b: Obj
|
||||
): boolean {
|
||||
export function isShallowEqual(a: unknown, b: unknown): boolean {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
if (typeof a !== typeof b) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a == null || b == null) {
|
||||
return false;
|
||||
}
|
||||
if (typeof a !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const keys = Object.keys(a);
|
||||
if (keys.length !== Object.keys(b).length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const key of keys) {
|
||||
if (a[key] !== b[key]) {
|
||||
if (
|
||||
(a as Record<string | number, unknown>)[key] !==
|
||||
(b as Record<string | number, unknown>)[key]
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue