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
+18 -2
View File
@@ -86,10 +86,15 @@ export default function PostsScreen() {
staleTime: 0,
});
const filteredPosts =
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" })}`);
@@ -139,6 +139,19 @@ export function PostCard({ post, onDelete, onLongPress }: PostCardProps) {
{truncatedContent}
</Text>
<View style={styles.footer}>
{integrations.length > 0 && (
<>
<Text style={[styles.accountName, { color: colors.mutedForeground }]} numberOfLines={1}>
{integrations
.slice(0, 2)
.map((i) => i.name || i.identifier || "")
.filter(Boolean)
.join(", ")}
{integrations.length > 2 ? ` +${integrations.length - 2}` : ""}
</Text>
<Text style={[styles.dot, { color: colors.mutedForeground }]}>·</Text>
</>
)}
<Feather name="clock" size={12} color={colors.mutedForeground} />
<Text style={[styles.date, { color: colors.mutedForeground }]}>
{formatDate(post.publishDate)}
@@ -191,6 +204,15 @@ const styles = StyleSheet.create({
fontSize: 12,
fontFamily: "Inter_400Regular",
},
accountName: {
fontSize: 12,
fontFamily: "Inter_400Regular",
flexShrink: 1,
},
dot: {
fontSize: 12,
marginHorizontal: 3,
},
deleteAction: {
width: 72,
alignItems: "center",