@@ -63,3 +63,23 @@ export function toDto(draft: Draft): GameDTO {
|
||||
export function nextOrder(games: GameDTO[]): number {
|
||||
return games.reduce((max, game) => Math.max(max, game.order ?? 0), 0) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the editor holds unsaved changes.
|
||||
*
|
||||
* Field by field rather than by comparing `JSON.stringify` output, which is
|
||||
* key-order dependent: it would report a clean draft as dirty the moment
|
||||
* `blankDraft` and `toDraft` listed their keys in a different order.
|
||||
*/
|
||||
export function isDirty(a: Draft, b: Draft): boolean {
|
||||
return (
|
||||
a.id !== b.id ||
|
||||
a.name !== b.name ||
|
||||
a.longName !== b.longName ||
|
||||
a.order !== b.order ||
|
||||
a.imgUrl !== b.imgUrl ||
|
||||
a.wordPressTag !== b.wordPressTag ||
|
||||
a.wordPressTagOs !== b.wordPressTagOs ||
|
||||
a.smashId !== b.smashId
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user