Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat(mobile): add loading indicator to buttons

daniel31x13ffee9d055169
diff --git a/apps/mobile/app/login.tsx b/apps/mobile/app/login.tsx
index e450babd..0a58ff26 100644
--- a/apps/mobile/app/login.tsx
+++ b/apps/mobile/app/login.tsx
@@ -17,6 +17,7 @@ export default function HomeScreen() {
const { auth, signIn } = useAuthStore();
const { colorScheme } = useColorScheme();
const [method, setMethod] = useState<"password" | "token">("password");
+ const [isLoading, setIsLoading] = useState(false);
const [form, setForm] = useState({
user: "",
@@ -161,12 +162,20 @@ export default function HomeScreen() {
<Button
variant="accent"
size="lg"
- onPress={() => {
+ isLoading={isLoading}
+ onPress={async () => {
if (
((form.user && form.password) || form.token) &&
form.instance
) {
- signIn(form.user, form.password, form.instance, form.token);
+ setIsLoading(true);
+ await signIn(
+ form.user,
+ form.password,
+ form.instance,
+ form.token
+ );
+ setIsLoading(false);
}
}}
>
diff --git a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
index 9f46ab92..0df62b37 100644
--- a/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/AddLinkSheet.tsx
@@ -50,6 +50,7 @@ export default function AddLinkSheet() {
}
)
}
+ isLoading={addLink.isPending}
variant="accent"
className="mb-2"
>
diff --git a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
index 624d9ab4..3e094d4f 100644
--- a/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
+++ b/apps/mobile/components/ActionSheets/EditLinkSheet.tsx
@@ -119,6 +119,7 @@ const Main = (props: SheetProps<"edit-link-sheet">) => {
},
})
}
+ isLoading={editLink.isPending}
variant="accent"
className="mb-2"
>
diff --git a/apps/mobile/store/auth.ts b/apps/mobile/store/auth.ts
index 127101a4..1d0cd832 100644
--- a/apps/mobile/store/auth.ts
+++ b/apps/mobile/store/auth.ts
@@ -10,10 +10,10 @@ type AuthStore = {
username: string,
password: string,
instance: string,
- token: string
- ) => void;
- signOut: () => void;
- setAuth: () => void;
+ token?: string
+ ) => Promise<void>;
+ signOut: () => Promise<void>;
+ setAuth: () => Promise<void>;
};
const useAuthStore = create<AuthStore>((set) => ({