Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

add open in app button to mod & modpack project pages #1731

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pages/[type]/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,16 @@
hoverOnly: true,
},
{ id: 'copy-id', action: () => copyId() },
...(isAppCompatible()
? [{ id: 'open-in-app', action: () => openInApp() }]
: []),
]"
:direction="cosmetics.projectLayout ? 'left' : 'right'"
>
<MoreHorizontalIcon />
<template #report> <ReportIcon /> Report </template>
<template #copy-id> <ClipboardCopyIcon /> Copy ID </template>
<template #open-in-app> <LinkIcon /> Open in App </template>
</OverflowMenu>
</template>
<template v-else>
Expand All @@ -356,12 +360,16 @@
hoverOnly: true,
},
{ id: 'copy-id', action: () => copyId() },
...(isAppCompatible()
? [{ id: 'open-in-app', action: () => openInApp() }]
: []),
]"
:direction="cosmetics.projectLayout ? 'left' : 'right'"
>
<MoreHorizontalIcon />
<template #report> <ReportIcon /> Report </template>
<template #copy-id> <ClipboardCopyIcon /> Copy ID </template>
<template #open-in-app> <LinkIcon /> Open in App </template>
</OverflowMenu>
</template>
</div>
Expand Down Expand Up @@ -1079,6 +1087,7 @@ import {
isStaff,
CheckIcon,
XIcon,
LinkIcon,
} from 'omorphia'
import CrownIcon from '~/assets/images/utils/crown.svg?component'
import CalendarIcon from '~/assets/images/utils/calendar.svg?component'
Expand Down Expand Up @@ -1502,6 +1511,22 @@ async function copyId() {
await navigator.clipboard.writeText(project.value.id)
}

function openInApp() {
window.location.href = `modrinth://mod/${project.value.id}`
}

function isAppCompatible() {
// checking against currently supported project types (as of 2024-06-15)
if (['mod', 'datapack', 'shader', 'resourcepack', 'modpack'].includes(project.value.project_type)) {
return true;
} else if (project.value.project_type === 'plugin') {
// allow plugins if they also support mod loaders
return tags.value.loaderData.modLoaders.some(t => project.value.loaders.includes(t));
} else {
return false;
}
}

const collapsedChecklist = ref(false)

const showModerationChecklist = ref(false)
Expand Down