Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,21 @@ defineExpose({
searchFilter.value = ''

const profilesVal = await list().catch(handleError)
for (const profile of profilesVal) {
profile.adding = false
profile.added = false
await Promise.allSettled(
profilesVal.map(async (profile) => {
profile.adding = false
profile.added = false

try {
const worlds = await get_profile_worlds(profile.path)
profile.added = worlds.some((w) => w.type === 'server' && w.address === serverAddress.value)
} catch {
// Ignore - will show as not added
}
}
try {
const worlds = await get_profile_worlds(profile.path)
profile.added = worlds.some(
(w) => w.type === 'server' && w.address === serverAddress.value,
)
} catch {
// Ignore - will show as not added
}
}),
)

profiles.value = profilesVal
modal.value.show()
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/pages/library/Custom.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import GridDisplay from '@/components/GridDisplay.vue'

defineProps({
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/pages/library/Downloaded.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import GridDisplay from '@/components/GridDisplay.vue'

defineProps({
Expand Down
5 changes: 3 additions & 2 deletions apps/app-frontend/src/pages/library/Index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import { PlusIcon } from '@modrinth/assets'
import { Button, injectNotificationManager } from '@modrinth/ui'
import { onUnmounted, ref, shallowRef } from 'vue'
Expand Down Expand Up @@ -41,7 +41,8 @@ onUnmounted(() => {
<NavTabs
:links="[
{ label: 'All instances', href: `/library` },
{ label: 'Downloaded', href: `/library/downloaded` },
{ label: 'Modpacks', href: `/library/modpacks` },
{ label: 'Servers', href: `/library/servers` },
{ label: 'Custom', href: `/library/custom` },
{ label: 'Shared with me', href: `/library/shared`, shown: false },
{ label: 'Saved', href: `/library/saved`, shown: false },
Expand Down
47 changes: 47 additions & 0 deletions apps/app-frontend/src/pages/library/Modpacks.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { computed, ref, watchEffect } from 'vue'

import GridDisplay from '@/components/GridDisplay.vue'
import { get_project_v3_many } from '@/helpers/cache.js'

const props = defineProps({
instances: {
type: Array,
required: true,
},
})

const serverProjectIds = ref(new Set())

const linkedInstances = computed(() => props.instances.filter((i) => i.linked_data))

watchEffect(async () => {
const projectIds = [
...new Set(linkedInstances.value.map((i) => i.linked_data?.project_id).filter(Boolean)),
]
if (projectIds.length === 0) {
serverProjectIds.value = new Set()
return
}

try {
const projects = await get_project_v3_many(projectIds, 'must_revalidate')
serverProjectIds.value = new Set(
projects.filter((p) => p?.minecraft_server != null).map((p) => p.id),
)
} catch {
serverProjectIds.value = new Set()
}
})

const filteredInstances = computed(() =>
linkedInstances.value.filter((i) => !serverProjectIds.value.has(i.linked_data?.project_id)),
)
</script>
<template>
<GridDisplay
v-if="filteredInstances && filteredInstances.length > 0"
label="Instances"
:instances="filteredInstances"
/>
</template>
2 changes: 1 addition & 1 deletion apps/app-frontend/src/pages/library/Overview.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import GridDisplay from '@/components/GridDisplay.vue'

defineProps({
Expand Down
47 changes: 47 additions & 0 deletions apps/app-frontend/src/pages/library/Servers.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { computed, ref, watchEffect } from 'vue'

import GridDisplay from '@/components/GridDisplay.vue'
import { get_project_v3_many } from '@/helpers/cache.js'

const props = defineProps({
instances: {
type: Array,
required: true,
},
})

const serverProjectIds = ref(new Set())

const linkedInstances = computed(() => props.instances.filter((i) => i.linked_data))

watchEffect(async () => {
const projectIds = [
...new Set(linkedInstances.value.map((i) => i.linked_data?.project_id).filter(Boolean)),
]
if (projectIds.length === 0) {
serverProjectIds.value = new Set()
return
}

try {
const projects = await get_project_v3_many(projectIds, 'must_revalidate')
serverProjectIds.value = new Set(
projects.filter((p) => p?.minecraft_server != null).map((p) => p.id),
)
} catch {
serverProjectIds.value = new Set()
}
})

const filteredInstances = computed(() =>
linkedInstances.value.filter((i) => serverProjectIds.value.has(i.linked_data?.project_id)),
)
</script>
<template>
<GridDisplay
v-if="filteredInstances && filteredInstances.length > 0"
label="Instances"
:instances="filteredInstances"
/>
</template>
4 changes: 3 additions & 1 deletion apps/app-frontend/src/pages/library/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Custom from './Custom.vue'
import Downloaded from './Downloaded.vue'
import Index from './Index.vue'
import Modpacks from './Modpacks.vue'
import Overview from './Overview.vue'
import Servers from './Servers.vue'

export { Custom, Downloaded, Index, Overview }
export { Custom, Downloaded, Index, Modpacks, Overview, Servers }
8 changes: 7 additions & 1 deletion apps/app-frontend/src/pages/project/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/>
<ProjectSidebarTags :project="data" class="project-sidebar-section" />
<ProjectSidebarCreators
:organization="null"
:organization="organization"
:members="members"
:org-link="(slug) => `https://modrinth.com/organization/${slug}`"
:user-link="(username) => `https://modrinth.com/user/${username}`"
Expand Down Expand Up @@ -248,6 +248,7 @@ import ContextMenu from '@/components/ui/ContextMenu.vue'
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
import NavTabs from '@/components/ui/NavTabs.vue'
import {
get_organization,
get_project,
get_project_v3,
get_team,
Expand Down Expand Up @@ -287,6 +288,7 @@ const data = shallowRef(null)
const versions = shallowRef([])
const members = shallowRef([])
const categories = shallowRef([])
const organization = shallowRef(null)
const instance = ref(null)
const instanceProjects = ref(null)

Expand Down Expand Up @@ -392,6 +394,10 @@ async function fetchProjectData() {
}
}

if (project.organization) {
organization.value = await get_organization(project.organization).catch(handleError)
}

isServerProject.value = projectV3.value?.minecraft_server != null
serverStatusOnline.value = !!projectV3.value?.minecraft_java_server?.ping?.data

Expand Down
10 changes: 10 additions & 0 deletions apps/app-frontend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ export default new createRouter({
name: 'Downloaded',
component: Library.Downloaded,
},
{
path: 'modpacks',
name: 'Modpacks',
component: Library.Modpacks,
},
{
path: 'servers',
name: 'LibraryServers',
component: Library.Servers,
},
{
path: 'custom',
name: 'Custom',
Expand Down
Loading