Skip to content

Commit

Permalink
Fix storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgustavo committed Aug 15, 2024
1 parent 66c9b86 commit 94f5341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/screens/home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useEffect, useLayoutEffect} from 'react';
import React, {useLayoutEffect} from 'react';
import {
ActivityIndicator,
SafeAreaView,
Expand All @@ -8,22 +8,17 @@ import {
import {useTheme} from '@react-navigation/native';

import {useAppDispatch, useAppSelector, RootState} from '../store';
import {notesInitialize} from '../store/app';
import {initialize} from '../store/app';
import {NoteObject} from '../store/app/app.types';

import Welcome from '../components/welcome';
import List from '../components/list';
import Error from '../components/error';
import styles from '../styles';

const Home = ({navigation}) => {
const dispatch = useAppDispatch();
const {colors} = useTheme();
const _notes = useAppSelector(({APP}: RootState) => APP.notes);
const [notes, setNotes] = useState<NoteObject[]>(_notes);

const [error, setError] = useState(false);
const [loaded, setLoaded] = useState(false);

useLayoutEffect(() => {
navigation.setOptions({
Expand All @@ -38,8 +33,11 @@ const Home = ({navigation}) => {
return (
<SafeAreaView
style={[styles.globalContainer, {backgroundColor: colors.background}]}>
{notes.length === 0 ? <Welcome navigation={navigation} /> : null}
{!error && <List notes={notes} navigation={navigation} />}
{_notes.length === 0 ? (
<Welcome navigation={navigation} />
) : (
<List notes={_notes} navigation={navigation} />
)}
</SafeAreaView>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/store/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export {
deleteNote,
updateNote,
} from './app.actions';
export {notesInitialize} from './app.effects';
export {initialize} from './app.effects';

0 comments on commit 94f5341

Please sign in to comment.