Skip to content

Commit

Permalink
Merge pull request #63 from codeforjapan/docs/note-post-id-null
Browse files Browse the repository at this point in the history
docs: 型的には必要ない分岐が入っている理由を書く
  • Loading branch information
sushichan044 authored Mar 10, 2025
2 parents 6044a64 + 4bb6e1e commit 038efe7
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions app/components/note/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,35 @@ export const Note = ({ note }: NoteProps) => {
</div>
</Stack>
<Post post={note.post} />
{isNonEmptyString(note.postId) && (
<Group justify="flex-end">
<Button
color="pink"
component="a"
href={postLinkFromPostId(note.postId)}
size="xs"
target="_blank"
variant="light"
>
ポストを見る
</Button>
<Button
color="pink"
component="a"
href={birdWatchLinkFromPostId(note.postId)}
size="xs"
target="_blank"
variant="light"
>
このポストについたノートを見る
</Button>
</Group>
)}
{
// ref: https://github.com/codeforjapan/BirdXplorer_Viewer/pull/32#discussion_r1978997326
// API 側で Post 情報を非同期に取得する仕様変更が予定されているが、誤って postId が null になってしまう場合がありえるので
// 予防的に分岐を入れている。Note.postId の存在が保証されている場合は分岐を削除して良い。
isNonEmptyString(note.postId) && (
<Group justify="flex-end">
<Button
color="pink"
component="a"
href={postLinkFromPostId(note.postId)}
size="xs"
target="_blank"
variant="light"
>
ポストを見る
</Button>
<Button
color="pink"
component="a"
href={birdWatchLinkFromPostId(note.postId)}
size="xs"
target="_blank"
variant="light"
>
このポストについたノートを見る
</Button>
</Group>
)
}
</Stack>
</Card>
);
Expand Down

0 comments on commit 038efe7

Please sign in to comment.