Skip to content

Commit cfd2977

Browse files
authored
feat: stable key for mods list (#4876)
1 parent 27fc079 commit cfd2977

File tree

1 file changed

+12
-2
lines changed
  • apps/frontend/src/pages/hosting/manage/[id]/content

1 file changed

+12
-2
lines changed

apps/frontend/src/pages/hosting/manage/[id]/content/index.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
width: '100%',
128128
}"
129129
>
130-
<template v-for="mod in visibleItems.items" :key="mod.filename">
130+
<template v-for="mod in visibleItems.items" :key="getStableModKey(mod)">
131131
<div
132132
class="relative mb-2 flex w-full items-center justify-between rounded-xl bg-bg-raised"
133133
:class="mod.disabled ? 'bg-table-alternateRow text-secondary' : ''"
@@ -245,7 +245,7 @@
245245
</div>
246246

247247
<input
248-
:id="`toggle-${mod.filename}`"
248+
:id="`toggle-${getStableModKey(mod)}`"
249249
:checked="!mod.disabled"
250250
:disabled="mod.changing"
251251
class="switch stylized-toggle"
@@ -595,6 +595,16 @@ function friendlyModName(mod: ContentItem) {
595595
return cleanName
596596
}
597597
598+
function getStableModKey(mod: ContentItem): string {
599+
if (mod.project_id) {
600+
return `project-${mod.project_id}`
601+
}
602+
603+
// external file
604+
const baseFilename = mod.filename.endsWith('.disabled') ? mod.filename.slice(0, -9) : mod.filename
605+
return `file-${baseFilename}`
606+
}
607+
598608
async function toggleMod(mod: ContentItem) {
599609
mod.changing = true
600610

0 commit comments

Comments
 (0)