Skip to content

Commit 1507862

Browse files
committed
address comments.
1 parent 8fd8aa5 commit 1507862

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/lib/stores/preferences.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { Models } from '@appwrite.io/console';
77
import { organization } from './organization';
88
import { page } from '$app/state';
99
import { user } from '$lib/stores/user';
10+
import deepEqual from 'deep-equal';
1011

1112
type Preferences = {
1213
limit?: number;
@@ -74,19 +75,17 @@ function createPreferences() {
7475
* Update the local store and then synchronizes them on user prefs.
7576
*/
7677
function updateAndSync(callback: (prefs: PreferencesStore) => void) {
77-
let oldPrefsSnapshot: string;
78+
let oldPrefsSnapshot: PreferencesStore;
7879
let newPrefsSnapshot: PreferencesStore;
7980

8081
update((currentPrefs) => {
81-
oldPrefsSnapshot = JSON.stringify(currentPrefs);
82+
oldPrefsSnapshot = currentPrefs;
8283
callback(currentPrefs);
8384
newPrefsSnapshot = currentPrefs;
8485
return currentPrefs;
8586
});
8687

87-
// Skip API if no changes (sufficient for simple objects).
88-
// The key order seemed to be maintained during local tests.
89-
if (oldPrefsSnapshot === JSON.stringify(newPrefsSnapshot)) {
88+
if (deepEqual(oldPrefsSnapshot, newPrefsSnapshot)) {
9089
return;
9190
}
9291

0 commit comments

Comments
 (0)