From c0523757791a0ed5a162ac76300989eee97a5692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20W=C4=85sowski?= Date: Fri, 24 Jan 2025 14:34:37 +0100 Subject: [PATCH 1/4] Removed unused code and artificial delay in login screen --- src/app/(public)/login.tsx | 78 +++++++++++--------------------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/src/app/(public)/login.tsx b/src/app/(public)/login.tsx index 507cc80..9fdf601 100644 --- a/src/app/(public)/login.tsx +++ b/src/app/(public)/login.tsx @@ -1,39 +1,14 @@ -import { Link, router, useNavigation } from 'expo-router' +import { Link } from 'expo-router' import { - Text, View, - Form, Button, YStack, Image, - Label, - Input, - Separator, - XStack, } from 'tamagui' -import { useAuth } from '@state/AuthProvider' -import { ActivityIndicator, Platform, SafeAreaView } from 'react-native' -import { useEffect, useState } from 'react' +import { Platform, SafeAreaView } from 'react-native' import { StatusBar } from 'expo-status-bar' export default function Login() { - const [server, setServer] = useState('pixelfed.social') - const [loading, setLoading] = useState(true) - - const { login, isLoading } = useAuth() - - const handleLogin = () => { - login(server) - } - - useEffect(() => { - const timer = setTimeout(() => { - setLoading(false) - }, 2000) - - return () => clearTimeout(timer) - }, []) - return ( - {isLoading || loading ? ( - - + + + - ) : ( - - - - - - - - - + + + + - )} + ) } From 3bac2d1a184ed3dd5dde61f66c1ea948d7ef18c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20W=C4=85sowski?= Date: Fri, 24 Jan 2025 15:20:41 +0100 Subject: [PATCH 2/4] Cleanup in manualLogin.tsx --- src/app/(public)/manualLogin.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/app/(public)/manualLogin.tsx b/src/app/(public)/manualLogin.tsx index cbd4206..a92681e 100644 --- a/src/app/(public)/manualLogin.tsx +++ b/src/app/(public)/manualLogin.tsx @@ -1,23 +1,19 @@ -import { Link, router, Stack, useNavigation, useRouter } from 'expo-router' +import { Stack, useRouter } from 'expo-router' import { Text, - View, Form, Button, YStack, Label, - Input, - Separator, - XStack, + Input } from 'tamagui' import { useAuth } from '@state/AuthProvider' -import { ActivityIndicator, SafeAreaView } from 'react-native' -import { useEffect, useState } from 'react' +import { SafeAreaView } from 'react-native' +import { useState } from 'react' import { StatusBar } from 'expo-status-bar' export default function Login() { const [server, setServer] = useState('') - const [loading, setLoading] = useState(true) const router = useRouter() const { login, isLoading } = useAuth() @@ -35,11 +31,7 @@ export default function Login() { alignItems: 'center', }} > - + From 73937cc471be5020c4a0ebc38a19b316c17a1acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20W=C4=85sowski?= Date: Fri, 24 Jan 2025 16:09:34 +0100 Subject: [PATCH 3/4] Fixed types in selectServer.tsx --- .vscode/settings.json | 5 ++++- src/app/(public)/selectServer.tsx | 17 +++++++++-------- src/lib/api-types.d.ts | 9 +++++++++ src/lib/api.ts | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 55712c1..8f5fb59 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "cSpell.words": [ + "Pixelfed" + ] } \ No newline at end of file diff --git a/src/app/(public)/selectServer.tsx b/src/app/(public)/selectServer.tsx index 8d6e2d7..352684e 100644 --- a/src/app/(public)/selectServer.tsx +++ b/src/app/(public)/selectServer.tsx @@ -1,10 +1,10 @@ import React, { useState, useMemo } from 'react' -import { Text, View, Button, YStack, Image, XStack } from 'tamagui' +import { StyleSheet } from 'react-native' +import { Text, View, Button, YStack, XStack } from 'tamagui' import { - ActivityIndicator, - Alert, FlatList, Keyboard, + ListRenderItemInfo, SafeAreaView, TextInput, TouchableOpacity, @@ -18,6 +18,7 @@ import { getOpenServers } from 'src/lib/api' import { enforceLen, prettyCount } from 'src/utils' import FastImage from 'react-native-fast-image' import { PressableOpacity } from 'react-native-pressable-opacity' +import { PixelfedServer } from 'src/lib/api-types' export default function Register() { const { data } = useQuery({ @@ -31,7 +32,7 @@ export default function Register() { const [searchQuery, setSearchQuery] = useState('') - const handleLogin = (server) => { + const handleLogin = (server: string) => { login(server) } @@ -46,7 +47,7 @@ export default function Register() { ) }, [data, searchQuery]) - const RenderItem = ({ item }) => ( + const RenderItem = ({ item }: ListRenderItemInfo) => (