Skip to content

Commit

Permalink
Add deepEqual utility and update Edit component for change detection (#…
Browse files Browse the repository at this point in the history
…38)

* Add deepEqual utility function and update Edit component to use it for change detection; add new Vite plugins and remove Firestore rules

* Vite Plugin order

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Refactor change detection in Edit component to use deepEqual utility function and remove commented-out legacy code

* Update vite-plugin-moment-timezone version to 0.0.4 in package.json
  • Loading branch information
JohanGrims authored Dec 10, 2024
1 parent be4b543 commit 7d447fc
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 4,950 deletions.
41 changes: 0 additions & 41 deletions firestore.rules

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"rollup-plugin-visualizer": "^5.12.0",
"vite": "^5.4.6",
"vite-plugin-compression2": "^0.12.0"
"vite-plugin-compression2": "^0.12.0",
"vite-plugin-moment-timezone": "0.0.4",
"vite-plugin-webpackchunkname": "^1.0.3"
}
}
117 changes: 117 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/admin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,25 @@ export function generateRandomHash(length = 4) {

return hash;
}

export const deepEqual = (a, b) => {
if (a === b) return true;
if (
typeof a !== "object" ||
a === null ||
typeof b !== "object" ||
b === null
)
return false;

const keysA = Object.keys(a);
const keysB = Object.keys(b);

if (keysA.length !== keysB.length) return false;

for (let key of keysA) {
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) return false;
}

return true;
};
Loading

0 comments on commit 7d447fc

Please sign in to comment.