feat(mobile): polish loading and search states
This commit is contained in:
parent
d56ccdec8c
commit
02dea5cd80
@ -9,6 +9,7 @@ import { colors } from '../../theme';
|
|||||||
|
|
||||||
export default function HomeScreen() {
|
export default function HomeScreen() {
|
||||||
const notes = useNotesStore((state: NotesState) => state.notes);
|
const notes = useNotesStore((state: NotesState) => state.notes);
|
||||||
|
const isLoading = useNotesStore((state: NotesState) => state.isLoading);
|
||||||
const workspaces = useWorkspaceStore((state: WorkspaceState) => state.workspaces);
|
const workspaces = useWorkspaceStore((state: WorkspaceState) => state.workspaces);
|
||||||
const activeWorkspaceId = useWorkspaceStore((state: WorkspaceState) => state.activeWorkspaceId);
|
const activeWorkspaceId = useWorkspaceStore((state: WorkspaceState) => state.activeWorkspaceId);
|
||||||
const setActiveWorkspace = useWorkspaceStore((state: WorkspaceState) => state.setActiveWorkspace);
|
const setActiveWorkspace = useWorkspaceStore((state: WorkspaceState) => state.setActiveWorkspace);
|
||||||
@ -56,6 +57,7 @@ export default function HomeScreen() {
|
|||||||
})}
|
})}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
{isLoading ? <Text style={styles.empty}>Loading notes…</Text> : null}
|
||||||
{recentNotes.map((note: (typeof recentNotes)[number]) => (
|
{recentNotes.map((note: (typeof recentNotes)[number]) => (
|
||||||
<Pressable key={note.id} onPress={() => router.push(`/note/${note.id}`)} style={styles.card}>
|
<Pressable key={note.id} onPress={() => router.push(`/note/${note.id}`)} style={styles.card}>
|
||||||
<View style={styles.badgeRow}>
|
<View style={styles.badgeRow}>
|
||||||
@ -65,7 +67,9 @@ export default function HomeScreen() {
|
|||||||
<Text style={styles.cardPreview}>{note.preview}</Text>
|
<Text style={styles.cardPreview}>{note.preview}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
))}
|
))}
|
||||||
{recentNotes.length === 0 ? <Text style={styles.empty}>No recent notes yet.</Text> : null}
|
{!isLoading && recentNotes.length === 0 ? (
|
||||||
|
<Text style={styles.empty}>No recent notes yet for this workspace.</Text>
|
||||||
|
) : null}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { colors } from '../../theme';
|
|||||||
export default function SearchScreen() {
|
export default function SearchScreen() {
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const notes = useNotesStore((state: NotesState) => state.notes);
|
const notes = useNotesStore((state: NotesState) => state.notes);
|
||||||
|
const isLoading = useNotesStore((state: NotesState) => state.isLoading);
|
||||||
const workspaces = useWorkspaceStore((state: WorkspaceState) => state.workspaces);
|
const workspaces = useWorkspaceStore((state: WorkspaceState) => state.workspaces);
|
||||||
const activeWorkspaceId = useWorkspaceStore((state: WorkspaceState) => state.activeWorkspaceId);
|
const activeWorkspaceId = useWorkspaceStore((state: WorkspaceState) => state.activeWorkspaceId);
|
||||||
const activeWorkspaceName =
|
const activeWorkspaceName =
|
||||||
@ -45,12 +46,15 @@ export default function SearchScreen() {
|
|||||||
style={styles.input}
|
style={styles.input}
|
||||||
/>
|
/>
|
||||||
<View style={styles.list}>
|
<View style={styles.list}>
|
||||||
|
{isLoading ? <Text style={styles.empty}>Loading searchable notes…</Text> : null}
|
||||||
{results.map((note: MobileNote) => (
|
{results.map((note: MobileNote) => (
|
||||||
<Pressable key={note.id} onPress={() => router.push(`/note/${note.id}`)} style={styles.row}>
|
<Pressable key={note.id} onPress={() => router.push(`/note/${note.id}`)} style={styles.row}>
|
||||||
<Text style={styles.rowText}>{note.title}</Text>
|
<Text style={styles.rowText}>{note.title}</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
))}
|
))}
|
||||||
{results.length === 0 ? <Text style={styles.empty}>No notes match your search yet.</Text> : null}
|
{!isLoading && results.length === 0 ? (
|
||||||
|
<Text style={styles.empty}>No notes match your search in this scope yet.</Text>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user