Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/app-frontend/src/components/ui/world/RecentWorldsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { LoaderCircleIcon } from '@modrinth/assets'
import type { GameVersion } from '@modrinth/ui'
import { GAME_MODES, HeadingLink, injectNotificationManager } from '@modrinth/ui'
import { platform } from '@tauri-apps/plugin-os'
import type { Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
Expand Down Expand Up @@ -48,6 +49,11 @@ const gameVersions = ref<GameVersion[]>(await get_game_versions().catch(() => []
const MIN_JUMP_BACK_IN = 3
const MAX_JUMP_BACK_IN = 6
const TWO_WEEKS_AGO = dayjs().subtract(14, 'day')
const MAX_LINUX_POPULATES = 3

// Track populate calls on Linux to prevent server ping spam
const isLinux = platform() === 'linux'
const linuxPopulateCount = ref(0)

type BaseJumpBackInItem = {
last_played: Dayjs
Expand Down Expand Up @@ -82,6 +88,10 @@ populateJumpBackIn()
})

async function populateJumpBackIn() {
// On Linux, limit automatic populates to prevent server ping spam
if (isLinux && linuxPopulateCount.value >= MAX_LINUX_POPULATES) return
if (isLinux) linuxPopulateCount.value++

console.info('Repopulating jump back in...')

const worldItems: WorldJumpBackInItem[] = []
Expand Down Expand Up @@ -230,6 +240,7 @@ const checkProcesses = async () => {

onMounted(() => {
checkProcesses()
linuxPopulateCount.value = 0
})

onUnmounted(() => {
Expand Down
9 changes: 9 additions & 0 deletions apps/app-frontend/src/pages/instance/Worlds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import {
RadialHeader,
} from '@modrinth/ui'
import type { Version } from '@modrinth/utils'
import { platform } from '@tauri-apps/plugin-os'
import { computed, onUnmounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'

Expand Down Expand Up @@ -214,6 +215,11 @@ const worldPlaying = ref<World>()
const worlds = ref<World[]>([])
const serverData = ref<Record<string, ServerData>>({})

// Track servers_updated calls on Linux to prevent server ping spam
const MAX_LINUX_REFRESHES = 3
const isLinux = platform() === 'linux'
const linuxRefreshCount = ref(0)

const protocolVersion = ref<ProtocolVersion | null>(
await get_profile_protocol_version(instance.value.path),
)
Expand All @@ -224,6 +230,9 @@ const unlistenProfile = await profile_listener(async (e: ProfileEvent) => {
console.info(`Handling profile event '${e.event}' for profile: ${e.profile_path_id}`)

if (e.event === 'servers_updated') {
if (isLinux && linuxRefreshCount.value >= MAX_LINUX_REFRESHES) return
if (isLinux) linuxRefreshCount.value++

await refreshAllWorlds()
}

Expand Down
Loading