diff --git a/src/App.js b/src/App.js index c2d032160..2db6545c7 100644 --- a/src/App.js +++ b/src/App.js @@ -263,6 +263,7 @@ function App() { // TODO: Should this be moved to Settings.loadUsrePreferences? api.getUserPreferences((preferences) => { + if (!preferences) return; SessionStorage.setAudioExercisesEnabled( preferences["audio_exercises"] === undefined || preferences["audio_exercises"] === "true", ); diff --git a/src/contexts/ProgressContext.js b/src/contexts/ProgressContext.js index 65099cbda..22173ec23 100644 --- a/src/contexts/ProgressContext.js +++ b/src/contexts/ProgressContext.js @@ -20,6 +20,7 @@ function ProgressProvider({ children }) { useEffect(() => { if (!userDetails?.learned_language) return; api.getDailyStreak((data) => { + if (!data) return; setDaysPracticed(data.daily_streak); }); }, [userDetails?.learned_language]); diff --git a/src/hooks/useSelectInterest.js b/src/hooks/useSelectInterest.js index 39a06d1c7..d7e7c21d6 100644 --- a/src/hooks/useSelectInterest.js +++ b/src/hooks/useSelectInterest.js @@ -10,16 +10,16 @@ export default function useSelectInterest(api) { useEffect(() => { api.getAvailableTopics((data) => { - setAvailableTopics(data); + if (data) setAvailableTopics(data); }); api.getSubscribedTopics((data) => { - setSubscribedTopics(data); + if (data) setSubscribedTopics(data); }); //custom interest filters api.getSubscribedSearchers((data) => { - setSubscribedSearches(data); + if (data) setSubscribedSearches(data); }); }, [api]); @@ -68,11 +68,7 @@ export default function useSelectInterest(api) { } function isSubscribed(topic) { - return subscribedTopics - .map((subscribedTopic) => subscribedTopic.id) - .includes(topic.id) - ? true - : false; + return subscribedTopics.some((t) => t.id === topic.id); } function subscribeToEmail(search) {