Fix the actual leaving issue

This commit is contained in:
Timo
2025-05-27 17:38:54 +02:00
parent b8951944ab
commit a1110af6d5

View File

@@ -42,6 +42,14 @@ export const useLocalStorage = (
};
export const setLocalStorageItem = (key: string, value: string): void => {
// Avoid unnecessary updates. Not avoiding them so can cause unexpected state updates across hooks.
// For instance:
// - In call view uses useRoomEncryptionSystem
// - This will set the key again.
// - All other instances of useRoomEncryptionSystem will now do a useMemo update of the e2eeSystem
// - because the dependency `storedPassword = useInternalRoomSharedKey(roomId);` would change.
if (localStorage.getItem(key) === value) return;
localStorage.setItem(key, value);
localStorageBus.emit(key, value);
};