batch corrections
- PostCard: fix post.status → post.state (all posts showed Draft) - compose: remove expo-file-system File import (not installed, Expo 54 incompatible) - compose: fix native FormData upload pattern for React Native - compose: add missing Bearer prefix on upload Authorization header - posts: memoize date range and include in query key to avoid stale closures Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import DateTimePicker from "@react-native-community/datetimepicker";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import { Image } from "expo-image";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { File } from "expo-file-system";
|
||||
import { fetch as expoFetch } from "expo/fetch";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
@@ -88,12 +87,15 @@ export default function ComposeScreen() {
|
||||
const blob = await response.blob();
|
||||
formData.append("file", blob, "upload.jpg");
|
||||
} else {
|
||||
const file = new File(imageUri);
|
||||
formData.append("file", file as unknown as Blob);
|
||||
formData.append("file", {
|
||||
uri: imageUri,
|
||||
name: "upload.jpg",
|
||||
type: "image/jpeg",
|
||||
} as unknown as Blob);
|
||||
}
|
||||
const uploadRes = await expoFetch(`${baseUrl}/upload`, {
|
||||
method: "POST",
|
||||
headers: { Authorization: apiKey },
|
||||
headers: { Authorization: `Bearer ${apiKey}` },
|
||||
body: formData,
|
||||
});
|
||||
const data = await uploadRes.json() as PostizUploadResult;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
@@ -54,20 +54,20 @@ export default function PostsScreen() {
|
||||
const [filter, setFilter] = useState<FilterType>("all");
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
|
||||
const start = new Date();
|
||||
start.setMonth(start.getMonth() - 3);
|
||||
const end = new Date();
|
||||
end.setMonth(end.getMonth() + 6);
|
||||
const { startDate, endDate } = useMemo(() => {
|
||||
const s = new Date();
|
||||
s.setMonth(s.getMonth() - 3);
|
||||
const e = new Date();
|
||||
e.setMonth(e.getMonth() + 6);
|
||||
return { startDate: s.toISOString(), endDate: e.toISOString() };
|
||||
}, []);
|
||||
|
||||
const { data: posts, isLoading, error, refetch } = useQuery<PostizPost[]>({
|
||||
queryKey: ["posts-list", !!client],
|
||||
queryKey: ["posts-list", !!client, startDate, endDate],
|
||||
queryFn: async () => {
|
||||
if (!client) return [];
|
||||
const res = await client.get("posts", {
|
||||
params: {
|
||||
startDate: start.toISOString(),
|
||||
endDate: end.toISOString(),
|
||||
},
|
||||
params: { startDate, endDate },
|
||||
});
|
||||
return Array.isArray(res.data) ? res.data : res.data?.posts ?? [];
|
||||
},
|
||||
@@ -91,9 +91,7 @@ export default function PostsScreen() {
|
||||
if (!client) return;
|
||||
try {
|
||||
await client.delete(`posts/${id}`);
|
||||
queryClient.setQueryData<PostizPost[]>(["posts-list", true], (old) =>
|
||||
(old ?? []).filter((p) => p.id !== id)
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: ["posts-list"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["posts"] });
|
||||
} catch (e: unknown) {
|
||||
const msg = extractError(e);
|
||||
|
||||
@@ -129,7 +129,7 @@ export function PostCard({ post, onDelete }: PostCardProps) {
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
<StatusBadge status={post.status} />
|
||||
<StatusBadge status={post.state} />
|
||||
</View>
|
||||
<Text style={[styles.content, { color: colors.foreground }]}>
|
||||
{truncatedContent}
|
||||
|
||||
Reference in New Issue
Block a user