diff --git a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue index 4f715f2d01..aef5332f83 100644 --- a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue +++ b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue @@ -15,20 +15,21 @@ import { get_all } from '@/helpers/process' import { kill, run } from '@/helpers/profile' import { get_game_versions } from '@/helpers/tags' import type { GameInstance } from '@/helpers/types' -import { - get_profile_protocol_version, - get_recent_worlds, - getWorldIdentifier, - hasServerQuickPlaySupport, - hasWorldQuickPlaySupport, - type ProtocolVersion, - refreshServerData, - type ServerData, - type ServerWorld, - start_join_server, - start_join_singleplayer_world, - type WorldWithProfile, -} from '@/helpers/worlds.ts' +import + { + get_profile_protocol_version, + get_recent_worlds, + getWorldIdentifier, + hasServerQuickPlaySupport, + hasWorldQuickPlaySupport, + type ProtocolVersion, + refreshServerData, + type ServerData, + type ServerWorld, + start_join_server, + start_join_singleplayer_world, + type WorldWithProfile, + } from '@/helpers/worlds.ts' import { handleSevereError } from '@/store/error' import { useTheming } from '@/store/theme.ts' @@ -79,7 +80,7 @@ watch([() => props.recentInstances, () => showWorlds.value], async () => { }) }) -populateJumpBackIn() +await populateJumpBackIn() .catch(() => { console.error('Failed to populate jump back in') }) diff --git a/packages/app-lib/src/api/worlds.rs b/packages/app-lib/src/api/worlds.rs index 44cbf2732a..6eb11e2e44 100644 --- a/packages/app-lib/src/api/worlds.rs +++ b/packages/app-lib/src/api/worlds.rs @@ -28,7 +28,6 @@ use std::io::Cursor; use std::path::{Path, PathBuf}; use std::sync::LazyLock; use tokio::io::AsyncWriteExt; -use tokio::task::JoinSet; use tokio_util::compat::FuturesAsyncWriteCompatExt; use url::Url; @@ -397,7 +396,6 @@ async fn get_server_worlds_in_profile( .await .ok(); - let first_server_index = worlds.len(); for (index, server) in servers.into_iter().enumerate() { if server.hidden { // TODO: Figure out whether we want to hide or show direct connect servers @@ -427,31 +425,6 @@ async fn get_server_worlds_in_profile( }; worlds.push(world); } - - if let Some(join_log) = join_log { - let mut futures = JoinSet::new(); - for (index, world) in worlds.iter().enumerate().skip(first_server_index) - { - // We can't check for the profile already having a last_played, in case the user joined - // the target address directly more recently. This is often the case when using - // quick-play before 1.20. - if let WorldDetails::Server { address, .. } = &world.details - && let Ok((host, port)) = parse_server_address(address) - { - let host = host.to_owned(); - futures.spawn(async move { - resolve_server_address(&host, port) - .await - .ok() - .map(|x| (index, x)) - }); - } - } - for (index, address) in futures.join_all().await.into_iter().flatten() { - worlds[index].last_played = join_log.get(&address).copied(); - } - } - Ok(()) } diff --git a/packages/app-lib/src/launcher/mod.rs b/packages/app-lib/src/launcher/mod.rs index db29817fb8..abfe6be4a8 100644 --- a/packages/app-lib/src/launcher/mod.rs +++ b/packages/app-lib/src/launcher/mod.rs @@ -8,6 +8,8 @@ use crate::launcher::quick_play_version::{ QuickPlayServerVersion, QuickPlayVersion, }; use crate::profile::QuickPlayType; +use crate::server_address::{ServerAddress, parse_server_address}; +use crate::state::server_join_log::JoinLogEntry; use crate::state::{ Credentials, JavaVersion, ProcessMetadata, ProfileInstallStage, }; @@ -614,6 +616,31 @@ pub async fn launch_minecraft( if let QuickPlayType::Server(address) = &mut quick_play_type && quick_play_version.server >= QuickPlayServerVersion::BuiltinLegacy { + // Record last-played for the original server address immediately so + // recent-worlds can match without DNS/SRV resolution. + let original = match address { + ServerAddress::Unresolved(address) => parse_server_address(address) + .ok() + .map(|(h, p)| (h.to_owned(), p)), + ServerAddress::Resolved { + original_host, + original_port, + .. + } => Some((original_host.clone(), *original_port)), + }; + if let Some((host, port)) = original + && let Err(e) = (JoinLogEntry { + profile_path: profile.path.clone(), + host, + port, + join_time: Utc::now(), + }) + .upsert(&state.pool) + .await + { + tracing::warn!("Failed to write server join log entry: {e}"); + } + address.resolve().await?; }