feat(mobile): add post creation and comments
Post creation: gallery/camera picker (expo-image-picker) uploads each image straight to Supabase Storage via a presigned PUT (posts.getPresignedUrl + expo-file-system), then posts.create with the resulting storage keys — reachable via a new "+" header button on the Feed tab. No client-side blurhash (browser Canvas API, no RN equivalent) or AI-disclosure/mention support yet, matching the rest of mobile's plain-text captions. Comments: a dedicated screen (posts/[postId]/comments) for reading, posting, and deleting one's own comments, reachable by tapping the comment icon on a PostCard. Ported from web's PostDetailDialog comment panel, scoped down to just that panel since mobile's image full-view already has its own route.
This commit is contained in:
1 parent
c1067b3245
commit
085d2abb53
10 files changed
+543
-15
No files matched your search
@@ -8,3 +8,4 @@ export type FeedPost = RouterOutputs["feed"]["getFeed"]["posts"][number];
|
||||
export type ExplorePet = RouterOutputs["explore"]["listPets"]["pets"][number];
|
||||
export type NotificationItem = RouterOutputs["notifications"]["list"]["notifications"][number];
|
||||
export type Conversation = RouterOutputs["conversations"]["list"][number];
|
||||
export type PostComment = RouterOutputs["comments"]["listByPost"]["comments"][number];
|
||||
@@ -92,10 +92,10 @@ export function PostCard({ post, actingPetId }: Props) {
|
||||
|
||||
<View style={styles.actions}>
|
||||
<PawButton postId={post.id} petId={actingPetId} initialCount={post.reactionCount ?? 0} />
|
||||
<View style={styles.actionGroup}>
|
||||
<Pressable style={styles.actionGroup} onPress={() => router.push(`/posts/${post.id}/comments`)}>
|
||||
<MessageCircle size={18} color={colors.quietGray} />
|
||||
<Text style={styles.actionCount}>{post.commentCount ?? 0}</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
<View style={styles.actionGroup}>
|
||||
<Repeat2 size={18} color={colors.quietGray} />
|
||||
<Text style={styles.actionCount}>{post.repostCount ?? 0}</Text>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { File } from "expo-file-system";
|
||||
|
||||
/**
|
||||
* PUTs a local picked-image file directly to the Supabase Storage presigned
|
||||
* URL returned by `posts.getPresignedUrl` — mirrors web's XHR PUT in
|
||||
* `src/lib/upload-xhr.ts`, using expo-file-system's `File.upload` instead
|
||||
* since RN has no XHR-with-progress primitive by default. Content-Type must
|
||||
* exactly match what was passed to `getPresignedUrl` or Supabase responds
|
||||
* with 400 SignatureDoesNotMatch.
|
||||
*/
|
||||
export async function uploadImageToSupabase(uri: string, presignedUrl: string, mimeType: string): Promise<void> {
|
||||
const file = new File(uri);
|
||||
const result = await file.upload(presignedUrl, {
|
||||
httpMethod: "PUT",
|
||||
mimeType,
|
||||
headers: { "Content-Type": mimeType },
|
||||
});
|
||||
|
||||
if (result.status < 200 || result.status >= 300) {
|
||||
throw new Error(`Upload fehlgeschlagen (Status ${result.status})`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user