feat(feedback): warn on long github issue urls (#140)
This commit is contained in:
@@ -3,6 +3,7 @@ import { ipcServices } from '@renderer/lib/ipc'
|
||||
import { Github, MessageCircle, Twitter } from 'lucide-react'
|
||||
import { type MouseEvent, useEffect, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
type AppInfo = {
|
||||
appVersion: string
|
||||
@@ -17,6 +18,7 @@ const FEEDBACK_UNKNOWN_VALUE = 'Unknown'
|
||||
const FEEDBACK_SOURCE_LABEL = 'Source URL'
|
||||
const FEEDBACK_ERROR_LABEL = 'Error'
|
||||
const FEEDBACK_COMMAND_LABEL = 'yt-dlp command'
|
||||
const FEEDBACK_MAX_GITHUB_URL_LENGTH = 7000
|
||||
|
||||
let cachedAppInfo: AppInfo | null = null
|
||||
let appInfoPromise: Promise<AppInfo> | null = null
|
||||
@@ -140,21 +142,18 @@ export const FeedbackLinkButtons = ({
|
||||
const tweetText = encodeURIComponent(
|
||||
tweetError ? `${tweetPrefix} - ${tweetError}` : tweetPrefix
|
||||
)
|
||||
const issueError = compactError ? clampText(compactError, 800) : FEEDBACK_UNKNOWN_ERROR
|
||||
const issueError = compactError || FEEDBACK_UNKNOWN_ERROR
|
||||
const resolvedSourceUrl = sourceUrl?.trim() || undefined
|
||||
const normalizedCommand = ytDlpCommand?.trim() || undefined
|
||||
const shouldIncludeLogs = Boolean(compactError || resolvedSourceUrl || normalizedCommand)
|
||||
const issueLogs = shouldIncludeLogs
|
||||
? clampText(
|
||||
buildIssueLogs(
|
||||
issueError,
|
||||
resolvedSourceUrl,
|
||||
normalizedCommand,
|
||||
FEEDBACK_SOURCE_LABEL,
|
||||
FEEDBACK_ERROR_LABEL,
|
||||
FEEDBACK_COMMAND_LABEL
|
||||
),
|
||||
800
|
||||
? buildIssueLogs(
|
||||
issueError,
|
||||
resolvedSourceUrl,
|
||||
normalizedCommand,
|
||||
FEEDBACK_SOURCE_LABEL,
|
||||
FEEDBACK_ERROR_LABEL,
|
||||
FEEDBACK_COMMAND_LABEL
|
||||
)
|
||||
: null
|
||||
const appVersionValue = appVersion ? `VidBee v${appVersion}` : FEEDBACK_UNKNOWN_VALUE
|
||||
@@ -209,6 +208,13 @@ export const FeedbackLinkButtons = ({
|
||||
useSimpleGithubUrl
|
||||
])
|
||||
|
||||
const handleLinkClick = (event: MouseEvent<HTMLAnchorElement>, href: string) => {
|
||||
if (href.startsWith('https://github.com') && href.length >= FEEDBACK_MAX_GITHUB_URL_LENGTH) {
|
||||
toast.info(t('download.feedback.githubUrlTooLong'))
|
||||
}
|
||||
onLinkClick?.(event)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{links.map((resource) => {
|
||||
@@ -221,7 +227,12 @@ export const FeedbackLinkButtons = ({
|
||||
className={buttonClassName}
|
||||
asChild
|
||||
>
|
||||
<a href={resource.href} target="_blank" rel="noreferrer" onClick={onLinkClick}>
|
||||
<a
|
||||
href={resource.href}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
onClick={(event) => handleLinkClick(event, resource.href)}
|
||||
>
|
||||
<Icon className={iconClassName} />
|
||||
{resource.label}
|
||||
</a>
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "الاشتراك"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "رابط GitHub هذا طويل جدًا. إذا لم يفتح، فالرجاء فتح صفحة المشكلة ولصق السجلات يدويًا."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Abonnement"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Dieser GitHub-Link ist sehr lang. Wenn er sich nicht öffnet, öffnen Sie bitte die Issue-Seite und fügen Sie die Logs manuell ein."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -131,7 +131,8 @@
|
||||
"fetch": "Fetch",
|
||||
"fetchingVideoInfo": "Fetching video info...",
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "This GitHub link is very long. If it fails to open, please open the issue page and paste the logs manually."
|
||||
},
|
||||
"history": "History",
|
||||
"imageLoadError": "Image failed to load",
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Suscripción"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Este enlace de GitHub es muy largo. Si no se abre, abre la página de la incidencia y pega los registros manualmente."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Abonnement"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Ce lien GitHub est très long. S'il ne s'ouvre pas, ouvrez la page de l'issue et collez les logs manuellement."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Berlangganan"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Tautan GitHub ini sangat panjang. Jika tidak terbuka, buka halaman issue dan tempel log secara manual."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Sottoscrizione"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Questo link GitHub è molto lungo. Se non si apre, apri la pagina dell'issue e incolla i log manualmente."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "サブスクリプション"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "このGitHubリンクは非常に長いです。開けない場合は、issueページを開いてログを手動で貼り付けてください。"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "신청"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "이 GitHub 링크가 매우 깁니다. 열리지 않으면 이슈 페이지를 열고 로그를 수동으로 붙여 넣어 주세요."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Subscrição"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Este link do GitHub é muito longo. Se não abrir, abra a página da issue e cole os logs manualmente."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "Подписка"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "Эта ссылка GitHub очень длинная. Если она не открывается, откройте страницу issue и вставьте логи вручную."
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "訂閱"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "這個 GitHub 連結很長。如果無法開啟,請開啟 issue 頁面並手動貼上日誌。"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
@@ -197,7 +197,8 @@
|
||||
"subscription": "订阅"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Report this error:"
|
||||
"title": "Report this error:",
|
||||
"githubUrlTooLong": "这个 GitHub 链接很长。如果无法打开,请打开 issue 页面并手动粘贴日志。"
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
|
||||
Reference in New Issue
Block a user