fix: server ping spam (#4983)

* add a throttle on populate jump back in list

* Revert "add a throttle on populate jump back in list"

This reverts commit b3e7f51b34936dd7487a51f2dab7170af19706cf.

* only allow populate jump back in list to run 3x on linux

* add temp debug logs

* Revert "add temp debug logs"

This reverts commit 8c5ec42fa3b48f11a416555ae7b366e44fa42b54.

* only allow 3x refresh limit for worlds list as well
This commit is contained in:
Truman Gao
2025-12-31 03:04:14 -08:00
committed by GitHub
parent d332032e53
commit 7fb6401613
2 changed files with 20 additions and 0 deletions

View File

@@ -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'
@@ -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),
)
@@ -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()
}