Skip to content

Commit 0fe6957

Browse files
authored
fix: try fix app freezing on instance page load (#6562)
* fix: app freezing fix * fix: fmt
1 parent 692f22b commit 0fe6957

2 files changed

Lines changed: 33 additions & 23 deletions

File tree

apps/app-frontend/src/pages/instance/Mods.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ onMounted(() => {
14431443
props.instance &&
14441444
event.instance_id === props.instance.id &&
14451445
event.event === 'synced' &&
1446-
props.instance.install_stage !== 'pack_installing' &&
1446+
props.instance.install_stage === 'installed' &&
14471447
!isBulkOperating.value
14481448
) {
14491449
await initProjects()

packages/app-lib/src/state/instances/commands/list_content.rs

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -209,29 +209,18 @@ pub(crate) async fn list_content(
209209
.await?;
210210
let imported_modpack_scope = is_imported_modpack_scope(&link);
211211
let linked_modpack_source_kind = linked_modpack_source_kind(&link);
212-
let mut failed_modpack_identifier_lookup = false;
213212
let modpack_ids = if imported_modpack_scope {
214213
None
215214
} else {
216215
match linked_modpack_ids(&link) {
217-
Some((_, version_id)) => match get_modpack_identifiers(
218-
&version_id,
219-
&resolved.content_set,
220-
&state.pool,
221-
&state.api_semaphore,
222-
)
223-
.await
224-
{
225-
Ok(ids) => Some(ids),
226-
Err(err) => {
227-
tracing::warn!(
228-
"Failed to fetch modpack identifiers: {}",
229-
err
230-
);
231-
failed_modpack_identifier_lookup = true;
232-
None
233-
}
234-
},
216+
Some((_, version_id)) => {
217+
get_cached_modpack_identifiers(
218+
&version_id,
219+
&state.pool,
220+
&state.api_semaphore,
221+
)
222+
.await?
223+
}
235224
None => None,
236225
}
237226
};
@@ -243,10 +232,9 @@ pub(crate) async fn list_content(
243232
}
244233
} else if let Some(ids) = modpack_ids.as_ref() {
245234
ContentFilter::ExcludeModpack(ids)
246-
} else if failed_modpack_identifier_lookup {
235+
} else if let Some(source_kind) = linked_modpack_source_kind {
247236
ContentFilter::ExcludeSourceKind {
248-
source_kind: linked_modpack_source_kind
249-
.unwrap_or(ContentSourceKind::ModrinthModpack),
237+
source_kind,
250238
exclude_untracked: true,
251239
}
252240
} else {
@@ -1182,6 +1170,28 @@ impl ModpackIdentifiers {
11821170
}
11831171
}
11841172

1173+
async fn get_cached_modpack_identifiers(
1174+
version_id: &str,
1175+
pool: &SqlitePool,
1176+
fetch_semaphore: &FetchSemaphore,
1177+
) -> crate::Result<Option<ModpackIdentifiers>> {
1178+
let Some(cached) =
1179+
CachedEntry::get_modpack_files(version_id, pool, fetch_semaphore)
1180+
.await?
1181+
else {
1182+
return Ok(None);
1183+
};
1184+
1185+
if cached.project_ids.is_empty() {
1186+
return Ok(None);
1187+
}
1188+
1189+
Ok(Some(ModpackIdentifiers {
1190+
hashes: cached.file_hashes.into_iter().collect(),
1191+
project_ids: cached.project_ids.into_iter().collect(),
1192+
}))
1193+
}
1194+
11851195
async fn get_modpack_identifiers(
11861196
version_id: &str,
11871197
content_set: &ContentSet,

0 commit comments

Comments
 (0)