fix: always check for updates/clear cache 10 min cooldown (#7077)

This commit is contained in:
Calum H.
2026-08-10 14:00:42 +00:00
committed by GitHub
parent 92971a3e0d
commit 9fd45ef2ce
10 changed files with 71 additions and 4 deletions
@@ -77,6 +77,10 @@ export async function get_content_items(
return await invoke('plugin:instance|instance_get_content_items', { instanceId, cacheBehaviour })
}
export async function refresh_content_updates(instanceId: string): Promise<void> {
return await invoke('plugin:instance|instance_refresh_content_updates', { instanceId })
}
// Linked modpack info returned from backend
export interface LinkedModpackInfo {
project: Labrinth.Projects.v2.Project
@@ -142,7 +142,7 @@ import {
isSharedInstanceUnavailableError,
type SharedInstanceUnavailableReason,
} from '@/helpers/install'
import { get_full_path, kill, remove, run } from '@/helpers/instance'
import { get_full_path, kill, refresh_content_updates, remove, run } from '@/helpers/instance'
import { useSharedInstanceErrors } from '@/helpers/shared-instance-errors'
import type { GameInstance } from '@/helpers/types'
import { createInstanceShortcut, showInstanceInFolder } from '@/helpers/utils.js'
@@ -194,6 +194,23 @@ useQuery(
})),
)
const instance = computed(() => instanceQuery.data.value)
useQuery(
computed(() => ({
queryKey: instanceKeys.contentUpdateCheck(instanceId.value),
queryFn: async () => {
const targetInstanceId = instanceId.value
await refresh_content_updates(targetInstanceId)
await queryClient.invalidateQueries({
queryKey: instanceKeys.content(targetInstanceId),
})
return targetInstanceId
},
enabled: !!instanceId.value && !offline.value && instance.value?.install_stage === 'installed',
staleTime: 10 * 60_000,
gcTime: 30 * 60_000,
retry: false,
})),
)
const linkedProjectId = computed(() => instance.value?.link?.project_id ?? '')
const linkedProjectQuery = useQuery(
computed(() => ({
@@ -11,6 +11,8 @@ export const instanceKeys = {
detail: (instanceId: string) => [...instanceKeys.all, 'summary', instanceId] as const,
processes: (instanceId: string) => [...instanceKeys.all, 'processes', instanceId] as const,
content: (instanceId: string) => [...instanceKeys.all, 'content', instanceId] as const,
contentUpdateCheck: (instanceId: string) =>
[...instanceKeys.all, 'content-update-check', instanceId] as const,
rootPath: (instanceId: string) => [...instanceKeys.detail(instanceId), 'root-path'] as const,
files: (instanceId: string, path: string) =>
[...instanceKeys.detail(instanceId), 'files', path] as const,
+1
View File
@@ -200,6 +200,7 @@ fn main() {
"instance_get_install_candidates",
"instance_content",
"instance_get_content_items",
"instance_refresh_content_updates",
"instance_get_dependencies_as_content_items",
"instance_get_linked_modpack_info",
"instance_get_linked_modpack_content",
+6
View File
@@ -30,6 +30,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
instance_get_install_candidates,
instance_content,
instance_get_content_items,
instance_refresh_content_updates,
instance_get_dependencies_as_content_items,
instance_get_linked_modpack_info,
instance_get_linked_modpack_content,
@@ -524,6 +525,11 @@ pub async fn instance_get_content_items(
)
}
#[tauri::command]
pub async fn instance_refresh_content_updates(instance_id: &str) -> Result<()> {
Ok(theseus::instance::refresh_content_updates(instance_id).await?)
}
#[tauri::command]
pub async fn instance_get_dependencies_as_content_items(
dependencies: Vec<Dependency>,