diff --git a/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue b/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue index 33485ddb6c..76f9ec6d01 100644 --- a/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue +++ b/apps/app-frontend/src/components/ui/skin/EditSkinModal.vue @@ -148,7 +148,6 @@ import { arrayBufferToBase64 } from '@modrinth/utils' import { computed, nextTick, ref, useTemplateRef, watch } from 'vue' import { - add_and_equip_custom_skin, type Cape, determineModelType, equip_skin, @@ -440,9 +439,22 @@ async function save() { const bytes: Uint8Array = new Uint8Array(await (await fetch(textureUrl)).arrayBuffer()) if (mode.value === 'new') { - const addedSkin = await add_and_equip_custom_skin(bytes, variant.value, selectedCape.value) + const addedSkin = await save_custom_skin( + { + texture_key: '', + variant: variant.value, + cape_id: selectedCape.value?.id, + texture: textureUrl, + source: 'custom', + is_equipped: false, + }, + bytes, + variant.value, + selectedCape.value, + true, + ) emit('saved', { - applied: true, + applied: false, skin: addedSkin, }) } else { diff --git a/apps/app-frontend/src/components/ui/skin/VirtualSkinSectionList.vue b/apps/app-frontend/src/components/ui/skin/VirtualSkinSectionList.vue index 22ba7c0c0e..9996726040 100644 --- a/apps/app-frontend/src/components/ui/skin/VirtualSkinSectionList.vue +++ b/apps/app-frontend/src/components/ui/skin/VirtualSkinSectionList.vue @@ -159,6 +159,9 @@ const sections = computed(() => [ const draggableSavedSkins = ref([]) const isDraggingSavedSkin = ref(false) const canReorderSavedSkins = computed(() => draggableSavedSkins.value.length > 1) +const fixedSavedSkins = computed(() => + props.savedSkins.filter((skin) => !canPersistSkinOrder(skin)), +) const sectionLayouts = computed(() => { const layouts: Array<{ section: SkinSection; top: number; height: number; index: number }> = [] @@ -223,7 +226,7 @@ watch( return } - draggableSavedSkins.value = [...nextSkins] + draggableSavedSkins.value = nextSkins.filter(canPersistSkinOrder) }, { immediate: true }, ) @@ -280,10 +283,18 @@ function savedSkinKey(skin: Skin) { return skinKey(skin, 'saved-skin') } +function canPersistSkinOrder(skin: Skin) { + return skin.source === 'custom' +} + function doSkinOrdersMatch(firstSkins: Skin[], secondSkins: Skin[]) { + const persistedSecondSkins = secondSkins.filter(canPersistSkinOrder) + return ( - firstSkins.length === secondSkins.length && - firstSkins.every((skin, index) => savedSkinKey(skin) === savedSkinKey(secondSkins[index])) + firstSkins.length === persistedSecondSkins.length && + firstSkins.every( + (skin, index) => savedSkinKey(skin) === savedSkinKey(persistedSecondSkins[index]), + ) ) } @@ -295,7 +306,7 @@ function onSavedSkinDragEnd() { isDraggingSavedSkin.value = false if (doSkinOrdersMatch(draggableSavedSkins.value, props.savedSkins)) { - draggableSavedSkins.value = [...props.savedSkins] + draggableSavedSkins.value = props.savedSkins.filter(canPersistSkinOrder) return } @@ -404,7 +415,7 @@ defineExpose({ getAddSkinButtonElement }) :list="draggableSavedSkins" class="grid w-full grid-cols-3 gap-3 min-[1300px]:grid-cols-4 min-[1750px]:grid-cols-5 min-[2050px]:grid-cols-6" :item-key="savedSkinKey" - :disabled="!canReorderSavedSkins" + :disabled="readOnly || !canReorderSavedSkins" :animation="250" :swap-threshold="1" :invert-swap="false" @@ -447,10 +458,50 @@ defineExpose({ getAddSkinButtonElement }) + + + + + +