diff --git a/artifacts/postiz-mobile/app/(tabs)/compose.tsx b/artifacts/postiz-mobile/app/(tabs)/compose.tsx index 042bb6a..6623b75 100644 --- a/artifacts/postiz-mobile/app/(tabs)/compose.tsx +++ b/artifacts/postiz-mobile/app/(tabs)/compose.tsx @@ -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; diff --git a/artifacts/postiz-mobile/app/(tabs)/posts.tsx b/artifacts/postiz-mobile/app/(tabs)/posts.tsx index f4e5575..ff4c6c2 100644 --- a/artifacts/postiz-mobile/app/(tabs)/posts.tsx +++ b/artifacts/postiz-mobile/app/(tabs)/posts.tsx @@ -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("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({ - 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(["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); diff --git a/artifacts/postiz-mobile/components/PostCard.tsx b/artifacts/postiz-mobile/components/PostCard.tsx index aaf8d7b..8518114 100644 --- a/artifacts/postiz-mobile/components/PostCard.tsx +++ b/artifacts/postiz-mobile/components/PostCard.tsx @@ -129,7 +129,7 @@ export function PostCard({ post, onDelete }: PostCardProps) { )} - + {truncatedContent}