Skip to content

Commit f9c358d

Browse files
committed
Merge remote-tracking branch 'origin' into cal/content-tab-rewrite-hosting
2 parents 70faae3 + 6efdfdf commit f9c358d

File tree

11 files changed

+147
-50
lines changed

11 files changed

+147
-50
lines changed

apps/app-frontend/src/components/ui/install_flow/ModInstallModal.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,21 @@ const reset_icon = () => {
159159
const createInstance = async () => {
160160
creatingInstance.value = true
161161
162-
const loader =
163-
versions.value[0].loaders[0] !== 'forge' &&
164-
versions.value[0].loaders[0] !== 'fabric' &&
165-
versions.value[0].loaders[0] !== 'quilt'
166-
? 'vanilla'
167-
: versions.value[0].loaders[0]
168-
169-
const id = await create(
170-
name.value,
171-
versions.value[0].game_versions[0],
172-
loader,
173-
'latest',
174-
icon.value,
175-
).catch(handleError)
162+
const gameVersions = versions.value[0].game_versions
163+
const gameVersion = gameVersions[0]
164+
165+
const loaders = versions.value[0].loaders
166+
const loader = loaders.contains('fabric')
167+
? 'fabric'
168+
: loaders.contains('neoforge')
169+
? 'neoforge'
170+
: loaders.contains('forge')
171+
? 'forge'
172+
: loaders.contains('quilt')
173+
? 'quilt'
174+
: 'vanilla'
175+
176+
const id = await create(name.value, gameVersion, loader, 'latest', icon.value).catch(handleError)
176177
177178
await installMod(id, versions.value[0].id).catch(handleError)
178179

apps/frontend/src/components/ui/NavTabs.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@
1818
v-if="link.icon"
1919
class="size-5"
2020
:class="{
21-
'text-brand': currentActiveIndex === index && !subpageSelected,
21+
'text-button-textSelected': currentActiveIndex === index && !subpageSelected,
2222
'text-secondary': currentActiveIndex !== index || subpageSelected,
2323
}"
2424
/>
25-
<span class="text-nowrap text-contrast">{{ link.label }}</span>
25+
<span
26+
class="text-nowrap"
27+
:class="{
28+
'text-button-textSelected': currentActiveIndex === index && !subpageSelected,
29+
'text-contrast': currentActiveIndex !== index || subpageSelected,
30+
}"
31+
>{{ link.label }}</span
32+
>
2633
</NuxtLink>
2734
</template>
2835
<template v-else>
@@ -39,14 +46,14 @@
3946
v-if="link.icon"
4047
class="size-5"
4148
:class="{
42-
'text-brand': currentActiveIndex === index && !subpageSelected,
49+
'text-button-textSelected': currentActiveIndex === index && !subpageSelected,
4350
'text-secondary': currentActiveIndex !== index || subpageSelected,
4451
}"
4552
/>
4653
<span
4754
class="text-nowrap"
4855
:class="{
49-
'text-brand': currentActiveIndex === index && !subpageSelected,
56+
'text-button-textSelected': currentActiveIndex === index && !subpageSelected,
5057
'text-contrast': currentActiveIndex !== index || subpageSelected,
5158
}"
5259
>{{ link.label }}</span

apps/frontend/src/components/ui/servers/FileItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function navigateToFolder() {
237237
const newPath = currentPath.endsWith('/')
238238
? `${currentPath}${props.name}`
239239
: `${currentPath}/${props.name}`
240-
router.push({ query: { path: newPath, page: 1 } })
240+
router.push({ query: { path: newPath } })
241241
}
242242
243243
const isNavigating = ref(false)

apps/frontend/src/pages/[type]/[id]/changelog.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,18 @@ watch(
144144
145145
const ids = paginated.map((v) => v.id)
146146
const versions = await labrinth.versions_v3.getVersions(toRaw(ids))
147+
versions.sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id))
147148
148-
paginatedVersions.value = paginated.map((version) => {
149+
paginatedVersions.value = paginated.map((version, index) => {
149150
const fullVersion = versions.find((v) => v.id === version.id)
150-
151-
if (fullVersion) return { ...version, changelog: fullVersion.changelog }
151+
if (fullVersion)
152+
return {
153+
...version,
154+
duplicate:
155+
!!fullVersion.changelog &&
156+
versions.slice(index + 1).some((v) => v.changelog === fullVersion.changelog),
157+
changelog: fullVersion.changelog,
158+
}
152159
else return version
153160
})
154161
},

apps/frontend/src/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ const { formatMessage } = useVIntl()
464464
const searchQuery = ref('leave')
465465
const sortType = ref('relevance')
466466
467-
const PROJECT_COUNT = 75000
467+
const PROJECT_COUNT = 100000
468468
const formatNumber = new Intl.NumberFormat().format
469469
const formattedProjectCount = computed(() => formatNumber(PROJECT_COUNT))
470470
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineNuxtPlugin } from '#imports'
2+
3+
export default defineNuxtPlugin((nuxt) => {
4+
if (import.meta.server) {
5+
nuxt.hooks.hook('app:rendered', (ctx) => {
6+
if (ctx.ssrContext?.payload?.data) {
7+
const check = (obj: any, path = 'payload') => {
8+
if (!obj || typeof obj !== 'object') return
9+
if (
10+
obj.constructor &&
11+
obj.constructor.name !== 'Object' &&
12+
obj.constructor.name !== 'Array'
13+
) {
14+
console.error(`Non-POJO at ${path}:`, obj.constructor.name)
15+
}
16+
for (const [k, v] of Object.entries(obj)) {
17+
check(v, `${path}.${k}`)
18+
}
19+
}
20+
check(ctx.ssrContext.payload.data)
21+
}
22+
})
23+
}
24+
})

apps/frontend/src/utils/analytics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { injectI18n } from '@modrinth/ui'
12
import dayjs from 'dayjs'
23
import { computed, ref, watch } from 'vue'
34

@@ -7,8 +8,7 @@ import { computed, ref, watch } from 'vue'
78
const { unix } = dayjs
89

910
export function useCountryNames(style = 'long') {
10-
const { $i18n } = useNuxtApp()
11-
const locale = $i18n.locale
11+
const { locale } = injectI18n()
1212
const displayNames = computed(
1313
() => new Intl.DisplayNames([locale.value], { type: 'region', style }),
1414
)

apps/labrinth/src/search/indexing/mod.rs

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use meilisearch_sdk::indexes::Index;
1414
use meilisearch_sdk::settings::{PaginationSetting, Settings};
1515
use sqlx::postgres::PgPool;
1616
use thiserror::Error;
17-
use tracing::{info, trace};
17+
use tracing::{Instrument, error, info, info_span, instrument, trace};
1818

1919
#[derive(Error, Debug)]
2020
pub enum IndexingError {
@@ -36,7 +36,7 @@ pub enum IndexingError {
3636
// is too large (>10MiB) then the request fails with an error. This chunk size
3737
// assumes a max average size of 4KiB per project to avoid this cap.
3838
const MEILISEARCH_CHUNK_SIZE: usize = 10000000;
39-
const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);
39+
const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(120);
4040

4141
pub async fn remove_documents(
4242
ids: &[crate::models::ids::VersionId],
@@ -167,6 +167,7 @@ pub async fn swap_index(
167167
Ok(())
168168
}
169169

170+
#[instrument(skip(config))]
170171
pub async fn get_indexes_for_indexing(
171172
config: &SearchConfig,
172173
next: bool, // Get the 'next' one
@@ -215,13 +216,13 @@ pub async fn get_indexes_for_indexing(
215216
Ok(results)
216217
}
217218

218-
#[tracing::instrument(skip_all, fields(%name))]
219+
#[instrument(skip_all, fields(name))]
219220
async fn create_or_update_index(
220221
client: &Client,
221222
name: &str,
222223
custom_rules: Option<&'static [&'static str]>,
223224
) -> Result<Index, meilisearch_sdk::errors::Error> {
224-
info!("Updating/creating index {}", name);
225+
info!("Updating/creating index");
225226

226227
match client.get_index(name).await {
227228
Ok(index) => {
@@ -236,9 +237,13 @@ async fn create_or_update_index(
236237
info!("Performing index settings set.");
237238
index
238239
.set_settings(&settings)
239-
.await?
240+
.await
241+
.inspect_err(|e| error!("Error setting index settings: {e:?}"))?
240242
.wait_for_completion(client, None, Some(TIMEOUT))
241-
.await?;
243+
.await
244+
.inspect_err(|e| {
245+
error!("Error setting index settings while waiting: {e:?}")
246+
})?;
242247
info!("Done performing index settings set.");
243248

244249
Ok(index)
@@ -250,7 +255,10 @@ async fn create_or_update_index(
250255
let task = client.create_index(name, Some("version_id")).await?;
251256
let task = task
252257
.wait_for_completion(client, None, Some(TIMEOUT))
253-
.await?;
258+
.await
259+
.inspect_err(|e| {
260+
error!("Error creating index while waiting: {e:?}")
261+
})?;
254262
let index = task
255263
.try_make_index(client)
256264
.map_err(|x| x.unwrap_failure())?;
@@ -263,15 +271,20 @@ async fn create_or_update_index(
263271

264272
index
265273
.set_settings(&settings)
266-
.await?
274+
.await
275+
.inspect_err(|e| error!("Error setting index settings: {e:?}"))?
267276
.wait_for_completion(client, None, Some(TIMEOUT))
268-
.await?;
277+
.await
278+
.inspect_err(|e| {
279+
error!("Error setting index settings while waiting: {e:?}")
280+
})?;
269281

270282
Ok(index)
271283
}
272284
}
273285
}
274286

287+
#[instrument(skip_all, fields(index.name, mods.len = mods.len()))]
275288
async fn add_to_index(
276289
client: &Client,
277290
index: &Index,
@@ -282,21 +295,31 @@ async fn add_to_index(
282295
"Adding chunk starting with version id {}",
283296
chunk[0].version_id
284297
);
298+
299+
let now = std::time::Instant::now();
300+
285301
index
286302
.add_or_replace(chunk, Some("version_id"))
287-
.await?
303+
.await
304+
.inspect_err(|e| error!("Error adding chunk to index: {e:?}"))?
288305
.wait_for_completion(
289306
client,
290307
None,
291-
Some(std::time::Duration::from_secs(3600)),
308+
Some(std::time::Duration::from_secs(7200)), // 2 hours
292309
)
293-
.await?;
294-
info!("Added chunk of {} projects to index", chunk.len());
310+
.await
311+
.inspect_err(|e| error!("Error adding chunk to index: {e:?}"))?;
312+
info!(
313+
"Added chunk of {} projects to index in {:.2} seconds",
314+
chunk.len(),
315+
now.elapsed().as_secs_f64()
316+
);
295317
}
296318

297319
Ok(())
298320
}
299321

322+
#[instrument(skip_all, fields(index.name))]
300323
async fn update_and_add_to_index(
301324
client: &Client,
302325
index: &Index,
@@ -357,20 +380,28 @@ pub async fn add_projects_batch_client(
357380

358381
let mut tasks = FuturesOrdered::new();
359382

383+
let mut id = 0;
384+
360385
client.across_all(index_references, |index_list, client| {
386+
let span = info_span!("add_projects_batch", client.idx = id);
387+
id += 1;
388+
361389
for index in index_list {
362390
let owned_client = client.clone();
363391
let projects_ref = &projects;
364392
let additional_fields_ref = &additional_fields;
365-
tasks.push_back(async move {
366-
update_and_add_to_index(
367-
&owned_client,
368-
index,
369-
projects_ref,
370-
additional_fields_ref,
371-
)
372-
.await
373-
});
393+
tasks.push_back(
394+
async move {
395+
update_and_add_to_index(
396+
&owned_client,
397+
index,
398+
projects_ref,
399+
additional_fields_ref,
400+
)
401+
.await
402+
}
403+
.instrument(span.clone()),
404+
);
374405
}
375406
});
376407

packages/ui/src/components/servers/files/explorer/FileItem.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function navigateToFolder() {
239239
const newPath = currentPath.endsWith('/')
240240
? `${currentPath}${props.name}`
241241
: `${currentPath}/${props.name}`
242-
router.push({ query: { path: newPath, page: 1 } })
242+
router.push({ query: { path: newPath } })
243243
}
244244
245245
const isNavigating = ref(false)
@@ -341,6 +341,12 @@ function handleDrop(event: DragEvent) {
341341

342342
<style scoped>
343343
.file-row-alt {
344+
background: color-mix(in srgb, var(--surface-2), black 3%);
345+
}
346+
347+
:global(.dark-mode) .file-row-alt,
348+
:global(.dark) .file-row-alt,
349+
:global(.oled-mode) .file-row-alt {
344350
background: color-mix(in srgb, var(--surface-2), black 10%);
345351
}
346352
</style>

packages/ui/src/pages/hosting/manage/files.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,15 @@ const {
424424
return client.kyros.files_v0.listDirectory(currentPath.value, pageParam, 100)
425425
},
426426
getNextPageParam: (lastPage, allPages) => {
427-
const totalFetched = allPages.reduce((sum, page) => sum + page.items.length, 0)
428-
return totalFetched < lastPage.total ? allPages.length + 1 : undefined
427+
const pageSize = 100
428+
if (lastPage.items.length >= pageSize) {
429+
return allPages.length + 1
430+
}
431+
432+
if (lastPage.current < lastPage.total) {
433+
return lastPage.current + 1
434+
}
435+
return undefined
429436
},
430437
staleTime: 30_000,
431438
initialPageParam: 1,

0 commit comments

Comments
 (0)