Skip to content

Commit

Permalink
update dev screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Svenstar74 committed Jun 27, 2024
1 parent 5c6aa5d commit 3c60771
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/features/dev/hooks/useSkipAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ function useSkipAnalytics() {
const [skipAnalytics, setSkipAnalytics] = useState(false);

function skipAnalyticsCheckboxHandler() {
analyticsService.trackAnalytics = skipAnalytics;
AsyncStorage.setItem('trackAnalytics', (skipAnalytics).toString());
setSkipAnalytics(current => !current);
const newValue = !skipAnalytics;
analyticsService.trackAnalytics = newValue;
AsyncStorage.setItem('trackAnalytics', newValue.toString());
setSkipAnalytics(newValue);
}

useEffect(() => {
AsyncStorage.getItem('trackAnalytics', (value) => {
if (value) {
setSkipAnalytics(true);
}
})
AsyncStorage.getItem('trackAnalytics')
.then((value) => {
const isSkipAnalytics = value === 'true';
analyticsService.trackAnalytics = !isSkipAnalytics;
setSkipAnalytics(isSkipAnalytics);
})
.catch((error) => {
console.error('Failed to load trackAnalytics from AsyncStorage', error);
});
}, []);

return {
skipAnalytics,
skipAnalyticsCheckboxHandler,
}
};
}

export default useSkipAnalytics
export default useSkipAnalytics;

0 comments on commit 3c60771

Please sign in to comment.