Task #5: Fix connection error logging, add android.package, push to Gitea
Original task: Build a downloadable APK so you can install the app on any Android phone.
What was done:
- eas.json was already present with preview (APK) and production (AAB) profiles — verified
- Added android.package "fr.gyozamancave.postizmobile" to app.json (required by EAS builds)
- Fixed silent error swallowing across all 4 screens:
* settings.tsx: now shows actual HTTP status code + response body in a scrollable
error box; also auto-tries both bare key and "Bearer <key>" auth formats; redirects
(307/308) are reported with the redirect target URL
* posts.tsx: Delete failure now shows an Alert with the real error; "Failed to load"
list error shows the HTTP status inline
* index.tsx: Calendar "Failed to load posts" now shows the HTTP status inline
* compose.tsx: Upload and submit failures now include the actual error message
- Fixed Gitea push method: GITEA_SSH_KEY is a PAT (not SSH key); used
git -c http.extraHeader=Authorization: token ... to authenticate and force-pushed
all changes to homegit.gyozamancave.fr/billisdead/Postiz-android.git
Deviations:
- APK not yet built: user has no Expo account (confirmed by user). EAS build requires
a free expo.dev account + interactive eas login. Proposed as follow-up task #7.
- Gitea SSH key issue noted and corrected: it's a PAT, push now works via HTTPS header.
Obsolete follow-up #6 may be retracted since push now works.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
FlatList,
|
||||
Platform,
|
||||
RefreshControl,
|
||||
@@ -11,11 +13,30 @@ import {
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { PostCard } from "@/components/PostCard";
|
||||
import { PostizPost, usePostiz } from "@/context/PostizContext";
|
||||
import { useColors } from "@/hooks/useColors";
|
||||
|
||||
function extractError(err: unknown): string {
|
||||
if (axios.isAxiosError(err)) {
|
||||
const status = err.response?.status;
|
||||
const data = err.response?.data;
|
||||
if (data) {
|
||||
const body =
|
||||
typeof data === "string"
|
||||
? data.slice(0, 200)
|
||||
: (data?.message ?? data?.error ?? JSON.stringify(data)).toString().slice(0, 200);
|
||||
return status ? `HTTP ${status}: ${body}` : body;
|
||||
}
|
||||
if (status) return `HTTP ${status} — ${err.message}`;
|
||||
if (err.message) return err.message;
|
||||
}
|
||||
if (err instanceof Error) return err.message;
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
type FilterType = "all" | "QUEUE" | "PUBLISHED" | "ERROR" | "DRAFT";
|
||||
|
||||
const FILTERS: { key: FilterType; label: string }[] = [
|
||||
@@ -74,7 +95,9 @@ export default function PostsScreen() {
|
||||
(old ?? []).filter((p) => p.id !== id)
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: ["posts"] });
|
||||
} catch (e) {
|
||||
} catch (e: unknown) {
|
||||
const msg = extractError(e);
|
||||
Alert.alert("Delete failed", msg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -155,6 +178,9 @@ export default function PostsScreen() {
|
||||
<Text style={[styles.emptyTitle, { color: colors.foreground }]}>
|
||||
Failed to load
|
||||
</Text>
|
||||
<Text style={[styles.emptyText, { color: colors.mutedForeground }]} selectable>
|
||||
{extractError(error)}
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
onPress={() => refetch()}
|
||||
style={[styles.retryBtn, { backgroundColor: colors.primary }]}
|
||||
|
||||
Reference in New Issue
Block a user