feat: hide post
This commit is contained in:
@@ -63,6 +63,13 @@ export function ScrollFeed({
|
|||||||
|
|
||||||
if (missing) notFound();
|
if (missing) notFound();
|
||||||
|
|
||||||
|
// When the owner views their own profile here and hides a post, drop it
|
||||||
|
// from the feed immediately (it moves to their Hidden tab). No-op for
|
||||||
|
// other viewers, who never see the Hide control.
|
||||||
|
function onHiddenChange(id: string, hidden: boolean) {
|
||||||
|
if (hidden) setFeed((rows) => rows.filter((p) => p.id !== id));
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-xl w-full mx-auto space-y-6">
|
<div className="max-w-xl w-full mx-auto space-y-6">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
@@ -70,7 +77,9 @@ export function ScrollFeed({
|
|||||||
) : feed.length === 0 ? (
|
) : feed.length === 0 ? (
|
||||||
<p className="text-sm text-muted-foreground">No posts yet.</p>
|
<p className="text-sm text-muted-foreground">No posts yet.</p>
|
||||||
) : (
|
) : (
|
||||||
feed.map((p) => <PostScrollCard key={p.id} post={p} />)
|
feed.map((p) => (
|
||||||
|
<PostScrollCard key={p.id} post={p} onHiddenChange={onHiddenChange} />
|
||||||
|
))
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ export default function MyPostsFeedPage() {
|
|||||||
setFeed((rows) => rows.map((p) => (p.id === updated.id ? updated : p)));
|
setFeed((rows) => rows.map((p) => (p.id === updated.id ? updated : p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hiding a post moves it off the timeline (into the Hidden tab), so drop
|
||||||
|
// it from this feed immediately rather than waiting for a refresh.
|
||||||
|
function onHiddenChange(id: string, hidden: boolean) {
|
||||||
|
if (hidden) setFeed((rows) => rows.filter((p) => p.id !== id));
|
||||||
|
}
|
||||||
|
|
||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -90,6 +96,7 @@ export default function MyPostsFeedPage() {
|
|||||||
post={p}
|
post={p}
|
||||||
onDelete={(id) => setPendingDelete(id)}
|
onDelete={(id) => setPendingDelete(id)}
|
||||||
onUpdated={onPostUpdated}
|
onUpdated={onPostUpdated}
|
||||||
|
onHiddenChange={onHiddenChange}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user