import { Linking, Pressable, StyleSheet, View } from 'react-native'; import { useTranslation } from 'react-i18next'; import { CommentItem } from '@/components/git/comment'; import { CommentComposer } from '@/components/git/comment-composer'; import { Markdown } from '@/components/git/markdown'; import { Screen } from '@/components/layout/screen'; import { AppText } from '@/components/ui/app-text'; import { Avatar } from '@/components/ui/avatar'; import { Badge, StatusBadge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Icon } from '@/components/ui/icon'; import { LabelChip } from '@/components/ui/label-chip'; import { ListItem } from '@/components/ui/list-item'; import { ErrorState, LoadingView } from '@/components/ui/state-views'; import { apiErrorMessage } from '@/core/api/error-text'; import { safeHost } from '@/core/api/instance-url'; import type { Comment } from '@/core/api/types'; import { flattenPages } from '@/core/utils/infinite'; import { useSession } from '@/features/accounts/use-session'; import { useCreateIssueComment, useDeleteIssueComment, useIssue, useIssueAttachments, useIssueComments, useIssueReactions, useIssueSubscription, useToggleIssueReaction, useToggleIssueSubscription, useUpdateIssue, useUpdateIssueComment, } from '@/features/issues/queries'; import { formatRelativeTime } from '@/core/utils/format'; import { useTheme } from '@/theme/theme-provider'; import { spacing } from '@/theme/tokens'; import type { RepositoryStackParamList } from '@/navigation/types'; import type { ScreenProps } from '@/navigation/typing'; type Props = ScreenProps; const REACTION_EMOJI: Record = { '+1': '๐Ÿ‘', '-1': '๐Ÿ‘Ž', laugh: '๐Ÿ˜„', hooray: '๐ŸŽ‰', confused: '๐Ÿ˜•', heart: 'โค๏ธ', rocket: '๐Ÿš€', eyes: '๐Ÿ‘€', }; /** Full issue view: state, author, labels, milestone, body, comments and composer. */ export function IssueDetailScreen({ navigation, route }: Props) { const { t } = useTranslation(); const { colors } = useTheme(); const { instance, account, token } = useSession(); const { owner, name, index } = route.params; const query = useIssue(owner, name, index); const issue = query.data; const commentsQuery = useIssueComments(owner, name, index); const updateIssue = useUpdateIssue(owner, name, index); const createComment = useCreateIssueComment(owner, name, index); const updateComment = useUpdateIssueComment(owner, name, index); const deleteComment = useDeleteIssueComment(owner, name, index); const reactionsQuery = useIssueReactions(owner, name, index); const toggleReaction = useToggleIssueReaction(owner, name, index); const attachmentsQuery = useIssueAttachments(owner, name, index); const subscription = useIssueSubscription(owner, name, index, account?.login); const toggleSubscription = useToggleIssueSubscription(owner, name, index, account?.login); if (query.isPending) return ; if (query.isError) { return ( void query.refetch()} /> ); } if (!issue) return null; const author = issue.user; const state = issue.state === 'closed' ? 'closed' : 'open'; const host = instance ? safeHost(instance.baseUrl) : null; const comments: Comment[] = flattenPages(commentsQuery.data); const toggleState = () => { updateIssue.mutate({ state: state === 'closed' ? 'open' : 'closed' }); }; return ( {issue.title} {`#${issue.number}`} {issue.is_locked ? {`#${issue.number}`} : null} {t('issues.openedBy', { name: author?.login ?? t('common.unknown') })} ยท{' '} {formatRelativeTime(issue.created_at, t)}