Skip to content

Commit 524cb16

Browse files
committed
fix: postId が存在する場合だけリンクを出す
1 parent 16e3b58 commit 524cb16

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

app/components/note/Note.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
postLinkFromNote,
88
} from "../../feature/twitter/link-builder";
99
import type { SearchedNote } from "../../generated/api/schemas";
10+
import { isNonEmptyString } from "../../utils/string";
1011
import { Post } from "../post/Post";
1112
import { NoteStatus } from "./NoteStatus";
1213
import { NoteTopic } from "./NoteTopics";
@@ -60,28 +61,30 @@ export const Note = ({ note }: NoteProps) => {
6061
</div>
6162
</Stack>
6263
<Post post={note.post} />
63-
<Group justify="flex-end">
64-
<Button
65-
color="pink"
66-
component="a"
67-
href={postLinkFromNote(note)}
68-
size="xs"
69-
target="_blank"
70-
variant="light"
71-
>
72-
ポストを見る
73-
</Button>
74-
<Button
75-
color="pink"
76-
component="a"
77-
href={birdWatchLinkFromNote(note)}
78-
size="xs"
79-
target="_blank"
80-
variant="light"
81-
>
82-
このポストについたノートを見る
83-
</Button>
84-
</Group>
64+
{isNonEmptyString(note.postId) && (
65+
<Group justify="flex-end">
66+
<Button
67+
color="pink"
68+
component="a"
69+
href={postLinkFromNote(note)}
70+
size="xs"
71+
target="_blank"
72+
variant="light"
73+
>
74+
ポストを見る
75+
</Button>
76+
<Button
77+
color="pink"
78+
component="a"
79+
href={birdWatchLinkFromNote(note)}
80+
size="xs"
81+
target="_blank"
82+
variant="light"
83+
>
84+
このポストについたノートを見る
85+
</Button>
86+
</Group>
87+
)}
8588
</Stack>
8689
</Card>
8790
);

app/utils/string.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const isNonEmptyString = (value?: unknown): value is string =>
2+
typeof value === "string" && value !== "";

0 commit comments

Comments
 (0)