fixes: post content tab release issues (#5566)
* fix: migrate old cache entries for CachedFileUpdate * feat: toggle goofy fix + switch version reimpl in app and panel * fix: multimc detection * fix: add tie breaker for sorting * feat: toggle hover state * fix: lint
This commit is contained in:
@@ -58,6 +58,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
import { ArrowLeftRightIcon, ClipboardCopyIcon, FolderOpenIcon } from '@modrinth/assets'
|
||||
import {
|
||||
ConfirmModpackUpdateModal,
|
||||
type ContentItem,
|
||||
@@ -158,6 +159,10 @@ const messages = defineMessages({
|
||||
id: 'app.instance.mods.copy-link',
|
||||
defaultMessage: 'Copy link',
|
||||
},
|
||||
switchVersion: {
|
||||
id: 'app.instance.mods.switch-version',
|
||||
defaultMessage: 'Switch version',
|
||||
},
|
||||
})
|
||||
|
||||
let savedModalState: ModpackContentModalState | null = null
|
||||
@@ -404,6 +409,34 @@ async function handleUpdate(id: string) {
|
||||
updatingProjectVersions.value = versions
|
||||
}
|
||||
|
||||
async function handleSwitchVersion(item: ContentItem) {
|
||||
if (!item.project?.id || !item.version?.id) return
|
||||
|
||||
updatingModpack.value = false
|
||||
updatingProject.value = item
|
||||
updatingProjectVersions.value = []
|
||||
loadingVersions.value = true
|
||||
loadingChangelog.value = false
|
||||
|
||||
await nextTick()
|
||||
|
||||
contentUpdaterModal.value?.show(item.version.id, { switchMode: true })
|
||||
|
||||
const versions = (await get_project_versions(item.project.id).catch((e) => {
|
||||
return handleError(e)
|
||||
})) as Labrinth.Versions.v2.Version[] | null
|
||||
|
||||
loadingVersions.value = false
|
||||
|
||||
if (!versions) return
|
||||
|
||||
versions.sort(
|
||||
(a, b) => new Date(b.date_published).getTime() - new Date(a.date_published).getTime(),
|
||||
)
|
||||
|
||||
updatingProjectVersions.value = versions
|
||||
}
|
||||
|
||||
async function handleModpackContentToggle(item: ContentItem) {
|
||||
await toggleDisableMod(item)
|
||||
}
|
||||
@@ -592,16 +625,26 @@ async function handleShareItems(
|
||||
}
|
||||
|
||||
function getOverflowOptions(item: ContentItem): OverflowMenuOption[] {
|
||||
const options: OverflowMenuOption[] = [
|
||||
{
|
||||
id: formatMessage(messages.showFile),
|
||||
action: () => highlightModInProfile(props.instance.path, item.file_path),
|
||||
},
|
||||
]
|
||||
const options: OverflowMenuOption[] = []
|
||||
|
||||
if (item.project?.id && item.version?.id && !item.has_update) {
|
||||
options.push({
|
||||
id: formatMessage(messages.switchVersion),
|
||||
icon: ArrowLeftRightIcon,
|
||||
action: () => handleSwitchVersion(item),
|
||||
})
|
||||
}
|
||||
|
||||
options.push({
|
||||
id: formatMessage(messages.showFile),
|
||||
icon: FolderOpenIcon,
|
||||
action: () => highlightModInProfile(props.instance.path, item.file_path),
|
||||
})
|
||||
|
||||
if (item.project?.slug) {
|
||||
options.push({
|
||||
id: formatMessage(messages.copyLink),
|
||||
icon: ClipboardCopyIcon,
|
||||
action: async () => {
|
||||
await navigator.clipboard.writeText(
|
||||
`https://modrinth.com/${item.project_type}/${item.project?.slug}`,
|
||||
|
||||
Reference in New Issue
Block a user