-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SunriseFox
committed
Nov 23, 2019
1 parent
9b42c94
commit 19cda93
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Group, Person } from '../database' | ||
|
||
export const PersonArrayComparer = (a: Person[], b: Person[]) => { | ||
if (a.length !== b.length) return false | ||
return a.every((person, index) => { | ||
const target = b[index] | ||
if (!person.identifier.equals(target.identifier)) return false | ||
if (person.avatar !== target.avatar) return false | ||
if (person.fingerprint !== target.fingerprint) return false | ||
if (person.groups.length !== target.groups.length) return false | ||
if (person.nickname !== target.nickname) return false | ||
if (person.previousIdentifiers?.length !== target.previousIdentifiers?.length) return false | ||
if (!person.groups.every((group, index) => target.groups[index].equals(group))) return false | ||
return true | ||
}) | ||
} | ||
|
||
export function GroupArrayComparer(a: Group[], b: Group[]) { | ||
if (a.length !== b.length) return false | ||
return a.every((group, index) => { | ||
const target = b[index] | ||
if (!group.identifier.equals(target.identifier)) return false | ||
if (group.avatar !== target.avatar) return false | ||
if (group.banned !== target.banned) return false | ||
if (group.groupName !== target.groupName) return false | ||
if (group.members.length !== target.members.length) return false | ||
if (!group.members.every((person, index) => target.members[index].equals(person))) return false | ||
return true | ||
}) | ||
} |