a18hvcryt: Delete the signed-in person's own post from its menu
This commit is contained in:
@@ -12,6 +12,8 @@ export interface CardMedia {
|
||||
export interface CardPost {
|
||||
key: string;
|
||||
id: string | null;
|
||||
/** The author's id on the feed, for matching against the signed-in feed user id. */
|
||||
authorId: string | null;
|
||||
authorName: string;
|
||||
authorPictureUrl: string | null;
|
||||
publishedAt: string | null;
|
||||
@@ -95,6 +97,8 @@ export function toCardPost(item: unknown, index = 0): CardPost | null {
|
||||
return {
|
||||
key: id ?? `${publishedAt ?? "unknown"}#${index}`,
|
||||
id,
|
||||
authorId:
|
||||
typeof author.id === "string" || typeof author.id === "number" ? String(author.id) : null,
|
||||
authorName: authorName(author),
|
||||
authorPictureUrl: str(author.profilePictureUrl),
|
||||
publishedAt,
|
||||
@@ -151,3 +155,8 @@ export function relativeTime(publishedAt: string | null, now: number = Date.now(
|
||||
if (d < 7) return `${d}d ago`;
|
||||
return new Date(t).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
||||
}
|
||||
|
||||
/** Delete is offered only on the signed-in person's own post. */
|
||||
export function canDelete(post: CardPost, feedUserId: string | null | undefined): boolean {
|
||||
return !!feedUserId && !!post.id && post.authorId !== null && post.authorId === feedUserId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user