fix(releases): проверять манифест и достоверность сведений о сборке
This commit is contained in:
1 parent
d5edfe5ef6
commit
1d27127b52
10 files changed
+135
-64
No files matched your search
@@ -16,9 +16,8 @@ import { formatAppVersionLabel, getAppVersion } from "@/lib/app-version"
|
||||
import {
|
||||
formatCommitSubject,
|
||||
getReleaseCommitPreview,
|
||||
RELEASE_COMMIT_PREVIEW_LIMIT,
|
||||
} from "@/lib/release-commits"
|
||||
import type { ReleaseManifest } from "@/lib/release-manifest"
|
||||
import {parseReleaseManifest,shouldShowReleaseNotes,type ReleaseManifest} from "@/lib/release-metadata"
|
||||
import { hasSeenReleaseModal, markReleaseModalSeen } from "@/lib/release-modal-storage"
|
||||
|
||||
export function ReleaseNotesModal() {
|
||||
@@ -27,26 +26,30 @@ export function ReleaseNotesModal() {
|
||||
|
||||
React.useEffect(() => {
|
||||
let cancelled = false
|
||||
const controller=new AbortController()
|
||||
const timeout=setTimeout(()=>controller.abort(),8000)
|
||||
|
||||
async function loadManifest() {
|
||||
try {
|
||||
const response = await fetch("/release-manifest.json", { cache: "no-store" })
|
||||
const response = await fetch("/release-manifest.json", { cache: "no-store", signal:controller.signal })
|
||||
if (!response.ok) return
|
||||
|
||||
const data = (await response.json()) as ReleaseManifest
|
||||
if (cancelled || !data.commits?.length || hasSeenReleaseModal(data.tag)) return
|
||||
const data = parseReleaseManifest(await response.json())
|
||||
if (cancelled || controller.signal.aborted || !data || !shouldShowReleaseNotes(data,getAppVersion()) || hasSeenReleaseModal(data.tag)) return
|
||||
|
||||
setManifest(data)
|
||||
setOpen(true)
|
||||
} catch {
|
||||
// Локальная сборка или недоступный manifest — модалку не показываем.
|
||||
}
|
||||
} finally {clearTimeout(timeout)}
|
||||
}
|
||||
|
||||
void loadManifest()
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
clearTimeout(timeout)
|
||||
controller.abort()
|
||||
}
|
||||
}, [])
|
||||
|
||||
@@ -68,7 +71,7 @@ export function ReleaseNotesModal() {
|
||||
Что нового в {versionLabel}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="text-sm leading-relaxed">
|
||||
Последние {RELEASE_COMMIT_PREVIEW_LIMIT} коммитов текущей сборки MikrotikManager.
|
||||
Коммиты текущей сборки MikrotikManager: {commits.length}.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -78,7 +81,7 @@ export function ReleaseNotesModal() {
|
||||
{commits.map((commit) => (
|
||||
<li
|
||||
key={commit.sha}
|
||||
className="rounded-lg border bg-card/80 p-3"
|
||||
className="rounded-lg border bg-card/80 p-3 break-words"
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<Badge variant="secondary" className="font-mono uppercase">
|
||||
@@ -99,6 +102,7 @@ export function ReleaseNotesModal() {
|
||||
<DialogFooter className="mx-0 mb-0 shrink-0 gap-3 border-t bg-muted/30 px-6 py-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<Button
|
||||
variant="outline"
|
||||
nativeButton={false}
|
||||
render={<Link href="/releases" />}
|
||||
onClick={() => handleOpenChange(false)}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user