mirror of
https://github.com/modrinth/code.git
synced 2026-09-05 06:19:11 +00:00
feat: only show duplicate tooltip if there are duplicates
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<h3 class="m-0 flex items-center gap-1.5 text-base font-semibold text-contrast">
|
<h3 class="m-0 flex items-center gap-1.5 text-base font-semibold text-contrast">
|
||||||
{{ sectionTitle }}
|
{{ sectionTitle }}
|
||||||
<InfoIcon
|
<InfoIcon
|
||||||
v-if="visibleDependencyRows.length > 0"
|
v-if="duplicateDependencyRowsHidden"
|
||||||
v-tooltip="formatMessage(messages.duplicateDependenciesHidden)"
|
v-tooltip="formatMessage(messages.duplicateDependenciesHidden)"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
class="size-4 text-secondary"
|
class="size-4 text-secondary"
|
||||||
@@ -253,6 +253,10 @@ const visibleDependencyRows = computed<DownloadDependencyRow[]>(() =>
|
|||||||
dedupeDependencyRows(dependencyRows.value),
|
dedupeDependencyRows(dependencyRows.value),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const duplicateDependencyRowsHidden = computed(() =>
|
||||||
|
hasDuplicateDependencyRows(dependencyRows.value),
|
||||||
|
)
|
||||||
|
|
||||||
const additionalFileRows = computed<DownloadDependencyRow[]>(() =>
|
const additionalFileRows = computed<DownloadDependencyRow[]>(() =>
|
||||||
props.additionalFiles.map((file) => ({
|
props.additionalFiles.map((file) => ({
|
||||||
key: `additional-file-${additionalFileKey(file)}`,
|
key: `additional-file-${additionalFileKey(file)}`,
|
||||||
@@ -396,6 +400,20 @@ function dependencyRowIdentity(row: DownloadDependencyRow) {
|
|||||||
return row.projectHref ?? row.downloadHref ?? row.key
|
return row.projectHref ?? row.downloadHref ?? row.key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasDuplicateDependencyRows(
|
||||||
|
rows: DownloadDependencyRow[],
|
||||||
|
seenDependencies = new Set<string>(),
|
||||||
|
): boolean {
|
||||||
|
for (const row of rows) {
|
||||||
|
const rowId = dependencyRowIdentity(row)
|
||||||
|
if (seenDependencies.has(rowId)) return true
|
||||||
|
seenDependencies.add(rowId)
|
||||||
|
if (hasDuplicateDependencyRows(row.dependencies, seenDependencies)) return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
function collectDownloadableDependencyFiles(
|
function collectDownloadableDependencyFiles(
|
||||||
rows: DownloadDependencyRow[],
|
rows: DownloadDependencyRow[],
|
||||||
seenHrefs = new Set<string>(),
|
seenHrefs = new Set<string>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user