fix: reschedule via delete+recreate, sort posts chrono, show account name

- Reschedule: Postiz public API v1 has no PUT/PATCH on posts; implement
  as delete + recreate with updated date and same content/integrations
- Posts list: sort ascending by publishDate so nearest post appears first
- PostCard footer: show integration name (or identifier) before the
  timestamp, truncated to 2 accounts with +N overflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
billisdead
2026-05-22 13:19:41 +02:00
parent e1a294fc96
commit 55d283c264
2 changed files with 43 additions and 5 deletions
+21 -5
View File
@@ -86,10 +86,15 @@ export default function PostsScreen() {
staleTime: 0,
});
const filteredPosts =
filter === "all"
? posts ?? []
: (posts ?? []).filter((p) => p.state === filter);
const filteredPosts = useMemo(() => {
const list =
filter === "all"
? posts ?? []
: (posts ?? []).filter((p) => p.state === filter);
return [...list].sort(
(a, b) => new Date(a.publishDate).getTime() - new Date(b.publishDate).getTime()
);
}, [posts, filter]);
const handleRefresh = async () => {
setRefreshing(true);
@@ -152,8 +157,19 @@ export default function PostsScreen() {
const submitReschedule = async (post: PostizPost, date: Date) => {
if (!client) return;
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
try {
await client.put(`posts/${post.id}`, { date: date.toISOString() });
await client.delete(`posts/${post.id}`);
await client.post("posts", {
type: "schedule",
date: date.toISOString(),
shortLink: false,
tags: [] as string[],
posts: integrations.map((intg) => ({
integration: { id: intg.id },
value: [{ content: post.content, image: post.image ?? [] }],
})),
});
queryClient.invalidateQueries({ queryKey: ["posts-list"] });
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
Alert.alert("Rescheduled", `Post moved to ${date.toLocaleDateString("en-US", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" })}`);