diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue
index d007db6bb..5ba7311c5 100644
--- a/apps/app-frontend/src/App.vue
+++ b/apps/app-frontend/src/App.vue
@@ -1,5 +1,5 @@
diff --git a/apps/app-frontend/src/components/ui/RunningAppBar.vue b/apps/app-frontend/src/components/ui/RunningAppBar.vue
index ef5248373..13c059ab4 100644
--- a/apps/app-frontend/src/components/ui/RunningAppBar.vue
+++ b/apps/app-frontend/src/components/ui/RunningAppBar.vue
@@ -15,7 +15,7 @@
-
@@ -111,10 +111,9 @@ import {
kill_by_uuid as killProfile,
get_uuids_by_profile_path as getProfileProcesses,
} from '@/helpers/process'
-import { loading_listener, process_listener, offline_listener } from '@/helpers/events'
+import { loading_listener, process_listener } from '@/helpers/events'
import { useRouter } from 'vue-router'
import { progress_bars_list } from '@/helpers/state.js'
-import { refreshOffline, isOffline } from '@/helpers/utils.js'
import ProgressBar from '@/components/ui/ProgressBar.vue'
import { handleError } from '@/store/notifications.js'
import { mixpanel_track } from '@/helpers/mixpanel'
@@ -132,12 +131,12 @@ const showProfiles = ref(false)
const currentProcesses = ref(await getRunningProfiles().catch(handleError))
const selectedProfile = ref(currentProcesses.value[0])
-const offline = ref(await isOffline().catch(handleError))
-const refreshInternet = async () => {
- offline.value = await refreshOffline().catch(handleError)
-}
-const unlistenRefresh = await offline_listener(async (b) => {
- offline.value = b
+const offline = ref(!navigator.onLine)
+window.addEventListener('offline', () => {
+ offline.value = true
+})
+window.addEventListener('online', () => {
+ offline.value = false
})
const unlistenProcess = await process_listener(async () => {
@@ -265,7 +264,6 @@ onBeforeUnmount(() => {
window.removeEventListener('click', handleClickOutsideProfile)
unlistenProcess()
unlistenLoading()
- unlistenRefresh()
})
diff --git a/apps/app-frontend/src/helpers/events.js b/apps/app-frontend/src/helpers/events.js
index d8899a78d..3bc07bcb9 100644
--- a/apps/app-frontend/src/helpers/events.js
+++ b/apps/app-frontend/src/helpers/events.js
@@ -17,7 +17,7 @@
// event.payload is the payload object
console.log(event)
})
-
+
Putting that in a script will print any emitted signal from rust
*/
import { listen } from '@tauri-apps/api/event'
@@ -93,15 +93,3 @@ export async function command_listener(callback) {
export async function warning_listener(callback) {
return await listen('warning', (event) => callback(event.payload))
}
-
-/// Payload for the 'offline' event
-/*
- OfflinePayload {
- offline: bool, true or false
- }
-*/
-export async function offline_listener(callback) {
- return await listen('offline', (event) => {
- return callback(event.payload)
- })
-}
diff --git a/apps/app-frontend/src/helpers/jre.js b/apps/app-frontend/src/helpers/jre.js
index 571588443..f490cbf77 100644
--- a/apps/app-frontend/src/helpers/jre.js
+++ b/apps/app-frontend/src/helpers/jre.js
@@ -14,6 +14,14 @@ JavaVersion {
*/
+export async function get_java_versions() {
+ return await invoke('plugin:jre|get_java_versions')
+}
+
+export async function set_java_version(version) {
+ return await invoke('plugin:jre|set_java_version', { version })
+}
+
// Finds all the installation of Java 7, if it exists
// Returns [JavaVersion]
export async function find_filtered_jres(version) {
diff --git a/apps/app-frontend/src/helpers/utils.js b/apps/app-frontend/src/helpers/utils.js
index 49757ee6e..5432ca710 100644
--- a/apps/app-frontend/src/helpers/utils.js
+++ b/apps/app-frontend/src/helpers/utils.js
@@ -48,22 +48,3 @@ export const releaseColor = (releaseType) => {
return ''
}
}
-
-export const openLink = (url) => {
- window.__TAURI_INVOKE__('tauri', {
- __tauriModule: 'Shell',
- message: {
- cmd: 'open',
- path: url,
- },
- })
-}
-
-export const refreshOffline = async () => {
- return await invoke('plugin:utils|refresh_offline', {})
-}
-
-// returns true/false
-export const isOffline = async () => {
- return await invoke('plugin:utils|is_offline', {})
-}
diff --git a/apps/app-frontend/src/pages/Browse.vue b/apps/app-frontend/src/pages/Browse.vue
index 723efbb8a..bd2163052 100644
--- a/apps/app-frontend/src/pages/Browse.vue
+++ b/apps/app-frontend/src/pages/Browse.vue
@@ -21,22 +21,17 @@ import { useRoute, useRouter } from 'vue-router'
import SearchCard from '@/components/ui/SearchCard.vue'
import SplashScreen from '@/components/ui/SplashScreen.vue'
import { useFetch } from '@/helpers/fetch.js'
-import {
- check_installed,
- get,
- get as getInstance,
- get_projects as getInstanceProjects,
-} from '@/helpers/profile.js'
+import { get as getInstance, get_projects as getInstanceProjects } from '@/helpers/profile.js'
import { convertFileSrc } from '@tauri-apps/api/tauri'
-import { isOffline } from '@/helpers/utils'
-import { offline_listener } from '@/helpers/events'
-
const router = useRouter()
const route = useRoute()
-const offline = ref(await isOffline())
-const unlistenOffline = await offline_listener((b) => {
- offline.value = b
+const offline = ref(!navigator.onLine)
+window.addEventListener('offline', () => {
+ offline.value = true
+})
+window.addEventListener('online', () => {
+ offline.value = false
})
const breadcrumbs = useBreadcrumbs()
@@ -527,8 +522,6 @@ const showLoaders = computed(
instanceContext.value === null) ||
ignoreInstanceLoaders.value,
)
-
-onUnmounted(() => unlistenOffline())
diff --git a/apps/app-frontend/src/pages/Index.vue b/apps/app-frontend/src/pages/Index.vue
index 4b902cd23..89856691e 100644
--- a/apps/app-frontend/src/pages/Index.vue
+++ b/apps/app-frontend/src/pages/Index.vue
@@ -3,12 +3,11 @@ import { ref, onUnmounted, shallowRef, computed } from 'vue'
import { useRoute } from 'vue-router'
import RowDisplay from '@/components/RowDisplay.vue'
import { list } from '@/helpers/profile.js'
-import { offline_listener, profile_listener } from '@/helpers/events'
+import { profile_listener } from '@/helpers/events'
import { useBreadcrumbs } from '@/store/breadcrumbs'
import { useFetch } from '@/helpers/fetch.js'
import { handleError } from '@/store/notifications.js'
import dayjs from 'dayjs'
-import { isOffline } from '@/helpers/utils'
const featuredModpacks = ref({})
const featuredMods = ref({})
@@ -21,7 +20,13 @@ breadcrumbs.setRootContext({ name: 'Home', link: route.path })
const recentInstances = shallowRef([])
-const offline = ref(await isOffline())
+const offline = ref(!navigator.onLine)
+window.addEventListener('offline', () => {
+ offline.value = true
+})
+window.addEventListener('online', () => {
+ offline.value = false
+})
const getInstances = async () => {
const profiles = await list(true).catch(handleError)
@@ -74,13 +79,6 @@ const unlistenProfile = await profile_listener(async (e) => {
}
})
-const unlistenOffline = await offline_listener(async (b) => {
- offline.value = b
- if (!b) {
- await Promise.all([getFeaturedModpacks(), getFeaturedMods()])
- }
-})
-
// computed sums of recentInstances, featuredModpacks, featuredMods, treating them as arrays if they are not
const total = computed(() => {
return (
@@ -92,7 +90,6 @@ const total = computed(() => {
onUnmounted(() => {
unlistenProfile()
- unlistenOffline()
})
diff --git a/apps/app-frontend/src/pages/Library.vue b/apps/app-frontend/src/pages/Library.vue
index e10a521b1..1902e651f 100644
--- a/apps/app-frontend/src/pages/Library.vue
+++ b/apps/app-frontend/src/pages/Library.vue
@@ -4,13 +4,12 @@ import GridDisplay from '@/components/GridDisplay.vue'
import { list } from '@/helpers/profile.js'
import { useRoute } from 'vue-router'
import { useBreadcrumbs } from '@/store/breadcrumbs'
-import { offline_listener, profile_listener } from '@/helpers/events.js'
+import { profile_listener } from '@/helpers/events.js'
import { handleError } from '@/store/notifications.js'
import { Button } from '@modrinth/ui'
import { PlusIcon } from '@modrinth/assets'
import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue'
import { NewInstanceImage } from '@/assets/icons'
-import { isOffline } from '@/helpers/utils'
const route = useRoute()
const breadcrumbs = useBreadcrumbs()
@@ -20,9 +19,12 @@ breadcrumbs.setRootContext({ name: 'Library', link: route.path })
const profiles = await list(true).catch(handleError)
const instances = shallowRef(Object.values(profiles))
-const offline = ref(await isOffline())
-const unlistenOffline = await offline_listener((b) => {
- offline.value = b
+const offline = ref(!navigator.onLine)
+window.addEventListener('offline', () => {
+ offline.value = true
+})
+window.addEventListener('online', () => {
+ offline.value = false
})
const unlistenProfile = await profile_listener(async () => {
@@ -31,7 +33,6 @@ const unlistenProfile = await profile_listener(async () => {
})
onUnmounted(() => {
unlistenProfile()
- unlistenOffline()
})
diff --git a/apps/app-frontend/src/pages/Settings.vue b/apps/app-frontend/src/pages/Settings.vue
index 8692714fb..1eb780afb 100644
--- a/apps/app-frontend/src/pages/Settings.vue
+++ b/apps/app-frontend/src/pages/Settings.vue
@@ -31,12 +31,14 @@ const accessSettings = async () => {
const fetchSettings = await accessSettings().catch(handleError)
const settings = ref(fetchSettings)
+console.log(fetchSettings)
// const settingsDir = ref(settings.value.loaded_config_dir)
-const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
-
+// const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
+const maxMemory = ref(100000)
watch(
settings,
async (oldSettings, newSettings) => {
+ console.log('hellooo')
if (oldSettings.loaded_config_dir !== newSettings.loaded_config_dir) {
return
}
@@ -83,14 +85,17 @@ watch(
{ deep: true },
)
+console.log('hellooo')
const credentials = ref(await getCreds().catch(handleError))
const loginScreenModal = ref()
+console.log('hellooo')
async function logOut() {
await logout().catch(handleError)
credentials.value = await getCreds().catch(handleError)
}
+console.log('hellooo')
async function signInAfter() {
loginScreenModal.value.hide()
credentials.value = await getCreds().catch(handleError)
diff --git a/apps/app-frontend/src/pages/instance/Index.vue b/apps/app-frontend/src/pages/instance/Index.vue
index 35db197aa..217321f0a 100644
--- a/apps/app-frontend/src/pages/instance/Index.vue
+++ b/apps/app-frontend/src/pages/instance/Index.vue
@@ -131,11 +131,11 @@ import {
get_uuids_by_profile_path,
kill_by_uuid,
} from '@/helpers/process'
-import { offline_listener, process_listener, profile_listener } from '@/helpers/events'
+import { process_listener, profile_listener } from '@/helpers/events'
import { useRoute, useRouter } from 'vue-router'
import { ref, onUnmounted } from 'vue'
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
-import { isOffline, showProfileInFolder } from '@/helpers/utils.js'
+import { showProfileInFolder } from '@/helpers/utils.js'
import ContextMenu from '@/components/ui/ContextMenu.vue'
import { mixpanel_track } from '@/helpers/mixpanel'
import { convertFileSrc } from '@tauri-apps/api/tauri'
@@ -162,7 +162,13 @@ breadcrumbs.setContext({
query: route.query,
})
-const offline = ref(await isOffline())
+const offline = ref(!navigator.onLine)
+window.addEventListener('offline', () => {
+ offline.value = true
+})
+window.addEventListener('online', () => {
+ offline.value = false
+})
const loadingBar = useLoading()
@@ -197,7 +203,7 @@ const checkProcess = async () => {
// Get information on associated modrinth versions, if any
const modrinthVersions = ref([])
-if (!(await isOffline()) && instance.value.linked_data && instance.value.linked_data.project_id) {
+if (!offline.value && instance.value.linked_data && instance.value.linked_data.project_id) {
modrinthVersions.value = await useFetch(
`https://api.modrinth.com/v2/project/${instance.value.linked_data.project_id}/version`,
'project',
@@ -295,14 +301,9 @@ const unlistenProcesses = await process_listener((e) => {
if (e.event === 'finished' && uuid.value === e.uuid) playing.value = false
})
-const unlistenOffline = await offline_listener((b) => {
- offline.value = b
-})
-
onUnmounted(() => {
unlistenProcesses()
unlistenProfiles()
- unlistenOffline()
})
diff --git a/apps/app-frontend/src/pages/instance/Mods.vue b/apps/app-frontend/src/pages/instance/Mods.vue
index 74632d59c..034b8c755 100644
--- a/apps/app-frontend/src/pages/instance/Mods.vue
+++ b/apps/app-frontend/src/pages/instance/Mods.vue
@@ -409,18 +409,17 @@ import { handleError } from '@/store/notifications.js'
import { mixpanel_track } from '@/helpers/mixpanel'
import { open } from '@tauri-apps/api/dialog'
import { listen } from '@tauri-apps/api/event'
-import { convertFileSrc } from '@tauri-apps/api/tauri'
import { highlightModInProfile } from '@/helpers/utils.js'
import { MenuIcon, ToggleIcon, TextInputIcon, AddProjectImage, PackageIcon } from '@/assets/icons'
import ExportModal from '@/components/ui/ExportModal.vue'
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
-import { $fetch } from 'ofetch'
import {
get_organization_many,
get_project_many,
get_team_many,
get_version_many,
} from '@/helpers/cache.js'
+import { profile_listener } from '@/helpers/events.js'
const router = useRouter()
@@ -449,193 +448,115 @@ const props = defineProps({
},
})
-const profileProjects = await get_projects(props.instance.path)
-const fetchProjects = []
-const fetchVersions = []
-const selectionMap = ref(new Map())
-
-for (const [key, value] of Object.entries(profileProjects)) {
- if (value.metadata.type === 'modrinth') {
- fetchProjects.push(value.metadata.project_id)
- fetchVersions.push(value.metadata.version_id)
+const unlistenProfiles = await profile_listener(async (event) => {
+ if (
+ event.profile_path_id === props.instance.path &&
+ event.event === 'synced' &&
+ props.instance.install_stage !== 'pack_installing'
+ ) {
+ await initProjects()
}
-}
-
-const [modrinthProjects, modrinthVersions] = await Promise.all([
- await get_project_many(fetchProjects).catch(handleError),
- await get_version_many(fetchVersions).catch(handleError),
-])
-
-const [modrinthTeams, modrinthOrganizations] = await Promise.all([
- await get_team_many(modrinthProjects.map((x) => x.team)).catch(handleError),
- await get_organization_many(modrinthProjects.map((x) => x.organization).filter((x) => !!x)).catch(
- handleError,
- ),
-])
-
-const projects = ref([])
-for (const [path, file] of Object.entries(profileProjects)) {
- if (file.metadata.type === 'modrinth') {
- const project = modrinthProjects.find((x) => file.metadata.project_id === x.id)
- const version = modrinthVersions.find((x) => file.metadata.version_id === x.id)
- const org = project.organization
- ? modrinthOrganizations.find((x) => x.id === project.organization)
- : null
-
- const team = modrinthTeams.find((x) => x[0].team_id === project.team)
-
- let owner = org ? org.name : team.find((x) => x.is_owner).user.username
-
- console.log(path)
- console.log(file)
- console.log(project)
- console.log(version)
- console.log(org)
- console.log(team)
-
- projects.value.push({
- path,
- name: project.title,
- slug: project.slug,
- author: owner,
- version: version.version_number,
- file_name: file.file_name,
- icon: project.icon_url,
- disabled: file.file_name.endsWith('.disabled'),
- updateVersion: file.update_version_id,
- outdated: !!file.update_version_id,
- project_type: project.project_type,
- id: project.id,
- })
-
- continue
- }
-
- if (file.metadata.type === 'inferred') {
- projects.value.push({
- path,
- name: file.metadata.title ?? file.file_name,
- author: file.metadata.authors[0],
- version: file.metadata.version,
- file_name: file.file_name,
- icon: file.metadata.icon ? convertFileSrc(file.metadata.icon) : null,
- disabled: file.disabled,
- outdated: false,
- project_type: file.metadata.project_type,
- })
- } else {
- projects.value.push({
- path,
- name: file.file_name.replace('.disabled', ''),
- author: '',
- version: null,
- file_name: file.file_name,
- icon: null,
- disabled: file.file_name.endsWith('.disabled'),
- outdated: false,
- project_type: null,
- })
- }
-}
-
-console.log(projects.value)
+})
-const newSelectionMap = new Map()
-for (const project of projects.value) {
- newSelectionMap.set(
- project.path,
- selectionMap.value.get(project.path) ??
- selectionMap.value.get(project.path.slice(0, -9)) ??
- selectionMap.value.get(project.path + '.disabled') ??
- false,
- )
-}
-selectionMap.value = newSelectionMap
+onUnmounted(() => {
+ unlistenProfiles()
+})
const showingOptions = ref(false)
const isPackLocked = computed(() => {
return props.instance.linked_data && props.instance.linked_data.locked
})
const canUpdatePack = computed(() => {
- if (!props.instance.linked_data) return false
- return props.instance.linked_data.version_id !== props.instance.modrinth_update_version
+ if (!props.instance.linked_data || !props.versions) return false
+ return props.instance.linked_data.version_id !== props.versions[0].id
})
const exportModal = ref(null)
-const initProjects = (initInstance) => {
- // projects.value = []
- // if (!initInstance || !initInstance.projects) return
- // for (const [path, project] of Object.entries(initInstance.projects)) {
- // if (project.metadata.type === 'modrinth' && !props.offline) {
- // let owner = project.metadata.members.find((x) => x.role === 'Owner')
- // projects.value.push({
- // path,
- // name: project.metadata.project.title,
- // slug: project.metadata.project.slug,
- // author: owner ? owner.user.username : null,
- // version: project.metadata.version.version_number,
- // file_name: project.file_name,
- // icon: project.metadata.project.icon_url,
- // updateVersion: project.metadata.update_version,
- // outdated: !!project.metadata.update_version,
- // project_type: project.metadata.project.project_type,
- // id: project.metadata.project.id,
- // })
- // } else if (project.metadata.type === 'inferred') {
- // projects.value.push({
- // path,
- // name: project.metadata.title ?? project.file_name,
- // author: project.metadata.authors[0],
- // version: project.metadata.version,
- // file_name: project.file_name,
- // icon: project.metadata.icon ? convertFileSrc(project.metadata.icon) : null,
- // disabled: project.disabled,
- // outdated: false,
- // project_type: project.metadata.project_type,
- // })
- // } else {
- // projects.value.push({
- // path,
- // name: project.file_name,
- // author: '',
- // version: null,
- // file_name: project.file_name,
- // icon: null,
- // disabled: project.disabled,
- // outdated: false,
- // project_type: null,
- // })
- // }
- // }
- //
- // const newSelectionMap = new Map()
- // for (const project of projects.value) {
- // newSelectionMap.set(
- // project.path,
- // selectionMap.value.get(project.path) ??
- // selectionMap.value.get(project.path.slice(0, -9)) ??
- // selectionMap.value.get(project.path + '.disabled') ??
- // false,
- // )
- // }
- // selectionMap.value = newSelectionMap
-}
+const projects = ref([])
+const selectionMap = ref(new Map())
-initProjects(props.instance)
+const initProjects = async () => {
+ const newProjects = []
-watch(
- () => props.instance.projects,
- () => {
- initProjects(props.instance)
- },
-)
+ const profileProjects = await get_projects(props.instance.path)
+ const fetchProjects = []
+ const fetchVersions = []
-watch(
- () => props.offline,
- () => {
- if (props.instance) initProjects(props.instance)
- },
-)
+ for (const value of Object.values(profileProjects)) {
+ if (value.metadata.type === 'modrinth') {
+ fetchProjects.push(value.metadata.project_id)
+ fetchVersions.push(value.metadata.version_id)
+ }
+ }
+
+ const [modrinthProjects, modrinthVersions] = await Promise.all([
+ await get_project_many(fetchProjects).catch(handleError),
+ await get_version_many(fetchVersions).catch(handleError),
+ ])
+
+ const [modrinthTeams, modrinthOrganizations] = await Promise.all([
+ await get_team_many(modrinthProjects.map((x) => x.team)).catch(handleError),
+ await get_organization_many(
+ modrinthProjects.map((x) => x.organization).filter((x) => !!x),
+ ).catch(handleError),
+ ])
+
+ for (const [path, file] of Object.entries(profileProjects)) {
+ if (file.metadata.type === 'modrinth') {
+ const project = modrinthProjects.find((x) => file.metadata.project_id === x.id)
+ const version = modrinthVersions.find((x) => file.metadata.version_id === x.id)
+ const org = project.organization
+ ? modrinthOrganizations.find((x) => x.id === project.organization)
+ : null
+
+ const team = modrinthTeams.find((x) => x[0].team_id === project.team)
+
+ let owner = org ? org.name : team.find((x) => x.is_owner).user.username
+
+ newProjects.push({
+ path,
+ name: project.title,
+ slug: project.slug,
+ author: owner,
+ version: version.version_number,
+ file_name: file.file_name,
+ icon: project.icon_url,
+ disabled: file.file_name.endsWith('.disabled'),
+ updateVersion: file.update_version_id,
+ outdated: !!file.update_version_id,
+ project_type: project.project_type,
+ id: project.id,
+ })
+ } else {
+ newProjects.push({
+ path,
+ name: file.file_name.replace('.disabled', ''),
+ author: '',
+ version: null,
+ file_name: file.file_name,
+ icon: null,
+ disabled: file.file_name.endsWith('.disabled'),
+ outdated: false,
+ project_type: file.project_type,
+ })
+ }
+ }
+
+ projects.value = newProjects
+
+ const newSelectionMap = new Map()
+ for (const project of projects.value) {
+ newSelectionMap.set(
+ project.path,
+ selectionMap.value.get(project.path) ??
+ selectionMap.value.get(project.path.slice(0, -9)) ??
+ selectionMap.value.get(project.path + '.disabled') ??
+ false,
+ )
+ }
+ selectionMap.value = newSelectionMap
+}
+await initProjects()
const modpackVersionModal = ref(null)
const installing = computed(() => props.instance.install_stage !== 'installed')
diff --git a/apps/app-frontend/src/pages/project/Index.vue b/apps/app-frontend/src/pages/project/Index.vue
index 8472140f3..a5ba1f40f 100644
--- a/apps/app-frontend/src/pages/project/Index.vue
+++ b/apps/app-frontend/src/pages/project/Index.vue
@@ -200,7 +200,6 @@
:project="data"
:versions="versions"
:members="members"
- :dependencies="dependencies"
:instance="instance"
:install="install"
:installed="installed"
@@ -256,7 +255,6 @@ import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { useRoute } from 'vue-router'
import { ref, shallowRef, watch } from 'vue'
-import { isOffline } from '@/helpers/utils'
import { useBreadcrumbs } from '@/store/breadcrumbs'
import { handleError } from '@/store/notifications.js'
import { convertFileSrc } from '@tauri-apps/api/tauri'
@@ -274,7 +272,6 @@ const installing = ref(false)
const data = shallowRef(null)
const versions = shallowRef([])
const members = shallowRef([])
-const dependencies = shallowRef([])
const categories = shallowRef([])
const instance = ref(null)
const instanceProjects = ref(null)
@@ -282,8 +279,6 @@ const instanceProjects = ref(null)
const installed = ref(false)
const installedVersion = ref(null)
-const offline = ref(await isOffline())
-
async function fetchProjectData() {
const project = await get_project(route.params.id).catch(handleError)
@@ -299,34 +294,6 @@ async function fetchProjectData() {
versions.value = versions.value.sort((a, b) => dayjs(b.date_published) - dayjs(a.date_published))
- const projectIds = new Set()
- const versionIds = new Set()
-
- for (const version of versions.value) {
- if (version.dependencies) {
- for (const dependency of version.dependencies) {
- if (dependency.project_id) {
- projectIds.add(dependency.project_id)
- }
- if (dependency.version_id) {
- versionIds.add(dependency.version_id)
- }
- }
- }
- }
-
- if (projectIds.size > 0 || versionIds.size > 0) {
- const [projectDeps, versionDeps] = await Promise.all([
- get_project_many([...projectIds]),
- get_version_many([...versionIds]),
- ])
-
- dependencies.value = {
- projects: projectDeps,
- versions: versionDeps,
- }
- }
-
if (instanceProjects.value) {
const installedFile = Object.values(instanceProjects.value).find(
(x) => x.metadata.type === 'modrinth' && x.metadata.project_id === data.value.id,
@@ -339,7 +306,7 @@ async function fetchProjectData() {
breadcrumbs.setName('Project', data.value.title)
}
-if (!offline.value) await fetchProjectData()
+await fetchProjectData()
watch(
() => route.params.id,
diff --git a/apps/app-frontend/src/pages/project/Version.vue b/apps/app-frontend/src/pages/project/Version.vue
index 79c620c0e..4ceea823d 100644
--- a/apps/app-frontend/src/pages/project/Version.vue
+++ b/apps/app-frontend/src/pages/project/Version.vue
@@ -190,6 +190,7 @@ import { ref, watch, computed } from 'vue'
import { useRoute } from 'vue-router'
import { useBreadcrumbs } from '@/store/breadcrumbs'
import { SwapIcon } from '@/assets/icons'
+import { get_project_many, get_version_many } from '@/helpers/cache.js'
const breadcrumbs = useBreadcrumbs()
@@ -204,10 +205,6 @@ const props = defineProps({
type: Array,
required: true,
},
- dependencies: {
- type: Object,
- required: true,
- },
members: {
type: Array,
required: true,
@@ -238,6 +235,7 @@ watch(
async () => {
if (route.params.version) {
version.value = props.versions.find((version) => version.id === route.params.version)
+ await refreshDisplayDependencies()
breadcrumbs.setName('Version', version.value.name)
}
},
@@ -247,11 +245,35 @@ const author = computed(() =>
props.members.find((member) => member.user.id === version.value.author_id),
)
-const displayDependencies = computed(() =>
- version.value.dependencies.map((dependency) => {
- const version = props.dependencies.versions.find((obj) => obj.id === dependency.version_id)
+const displayDependencies = ref({})
+
+async function refreshDisplayDependencies() {
+ const projectIds = new Set()
+ const versionIds = new Set()
+ if (version.value.dependencies) {
+ for (const dependency of version.value.dependencies) {
+ if (dependency.project_id) {
+ projectIds.add(dependency.project_id)
+ }
+ if (dependency.version_id) {
+ versionIds.add(dependency.version_id)
+ }
+ }
+ }
+ const [projectDeps, versionDeps] = await Promise.all([
+ get_project_many([...projectIds]),
+ get_version_many([...versionIds]),
+ ])
+
+ const dependencies = {
+ projects: projectDeps,
+ versions: versionDeps,
+ }
+
+ displayDependencies.value = version.value.dependencies.map((dependency) => {
+ const version = dependencies.versions.find((obj) => obj.id === dependency.version_id)
if (version) {
- const project = props.dependencies.projects.find(
+ const project = dependencies.projects.find(
(obj) => obj.id === version.project_id || obj.id === dependency.project_id,
)
return {
@@ -261,7 +283,7 @@ const displayDependencies = computed(() =>
link: `/project/${project.slug}/version/${version.id}`,
}
} else {
- const project = props.dependencies.projects.find((obj) => obj.id === dependency.project_id)
+ const project = dependencies.projects.find((obj) => obj.id === dependency.project_id)
if (project) {
return {
@@ -279,8 +301,9 @@ const displayDependencies = computed(() =>
}
}
}
- }),
-)
+ })
+}
+await refreshDisplayDependencies()