You've already forked AstralRinth
forked from didirus/AstralRinth
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:
@@ -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'
|
||||
@@ -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
|
||||
@@ -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[] = []
|
||||
@@ -230,6 +240,7 @@ const checkProcesses = async () => {
|
||||
|
||||
onMounted(() => {
|
||||
checkProcesses()
|
||||
linuxPopulateCount.value = 0
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user