ssr errors mitigation

This commit is contained in:
Igor Loskutov
2025-06-19 12:10:08 -04:00
parent 66baf51ccb
commit ff291a3ec8
3 changed files with 23 additions and 11 deletions

View File

@@ -36,7 +36,9 @@ export const RecordingConsentProvider: React.FC<RecordingConsentProviderProps> =
const safeWriteToStorage = (meetingIds: string[]): void => {
try {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(meetingIds));
if (typeof window !== 'undefined' && window.localStorage) {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(meetingIds));
}
} catch (error) {
console.error("Failed to save consent data to localStorage:", error);
}
@@ -69,6 +71,11 @@ export const RecordingConsentProvider: React.FC<RecordingConsentProviderProps> =
// initialize on mount
useEffect(() => {
try {
if (typeof window === 'undefined' || !window.localStorage) {
setState({ ready: true, consentAnsweredForMeetings: new Set() });
return;
}
const stored = localStorage.getItem(LOCAL_STORAGE_KEY);
if (!stored) {
setState({ ready: true, consentAnsweredForMeetings: new Set() });