Servers fixes

This commit is contained in:
Prospector
2025-06-03 16:15:57 -07:00
parent 3f77ab19ed
commit 4e8ebb5e5c
8 changed files with 66 additions and 29 deletions

View File

@@ -2,6 +2,7 @@
import { $fetch, FetchError } from "ofetch";
import type { ServerNotice } from "@modrinth/utils";
import type { FilesystemOp, FSQueuedOp, WSBackupState, WSBackupTask } from "~/types/servers.ts";
import { usePyroFetch } from "~/composables/pyroFetch.ts";
interface PyroFetchOptions {
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
@@ -1224,6 +1225,13 @@ const modules: any = {
suspend: suspendServer,
getMotd,
setMotd,
endIntro: async () => {
await usePyroFetch(`servers/${internalServerReference.value.serverId}/flows/intro`, {
method: "DELETE",
version: 1,
});
await internalServerReference.value.refresh(["general"]);
},
},
content: {
get: async (serverId: string) => {
@@ -1454,6 +1462,8 @@ type GeneralFunctions = {
* @deprecated Use fs.downloadFile instead
*/
fetchConfigFile: (fileName: string) => Promise<any>;
endIntro: () => Promise<void>;
};
type ContentFunctions = {

View File

@@ -905,7 +905,7 @@ function pingRegions() {
}
const PING_COUNT = 20;
const PING_INTERVAL = 400;
const PING_INTERVAL = 200;
const MAX_PING_TIME = 1000;
function runPingTest(region, index = 1) {

View File

@@ -862,11 +862,8 @@ const newLoaderVersion = ref<string | null>(null);
const newMCVersion = ref<string | null>(null);
const onReinstall = (potentialArgs: any) => {
if (serverData.value?.flows?.intro) {
usePyroFetch(`servers/${server.serverId}/flows/intro`, {
method: "DELETE",
version: 1,
});
if (serverData.value?.flows?.intro && server.general?.project) {
server.general?.endIntro();
}
if (!serverData.value) return;
@@ -1188,6 +1185,10 @@ onMounted(() => {
connectWebSocket();
}
if (server.general?.flows?.intro && server.general?.project) {
server.general?.endIntro();
}
if (username.value && email.value && userId.value && createdAt.value) {
const currentUser = auth.value?.user as any;
const matches =

View File

@@ -168,11 +168,19 @@ const fuse = computed(() => {
});
});
function introToTop(array: Server[]): Server[] {
return array.slice().sort((a, b) => {
return Number(b.flows?.intro) - Number(a.flows?.intro);
});
}
const filteredData = computed(() => {
if (!searchInput.value.trim()) {
return serverList.value;
return introToTop(serverList.value);
}
return fuse.value ? fuse.value.search(searchInput.value).map((result) => result.item) : [];
return fuse.value
? introToTop(fuse.value.search(searchInput.value).map((result) => result.item))
: [];
});
const previousServerList = ref<Server[]>([]);