Skip to content
Merged
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
17 changes: 14 additions & 3 deletions src/apps/core/switchserver/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MessageBox } from "$ts/util/dialog";
import { Store } from "$ts/writable";
import type { App, AppProcessData } from "$types/app";
import type { ServerOption } from "$types/server";

import Cookies from "js-cookie";
export class SwitchServerRuntime extends AppProcess {
servers = Store<ServerOption[]>([]);
selected = Store<string>();
Expand Down Expand Up @@ -45,11 +45,22 @@ export class SwitchServerRuntime extends AppProcess {
this.loading.set(true);
this.connectionError.set(false);

const currentServer = Server.url;

const result = await Server.switchServer(server.url);

this.loading.set(false);
if (!result) this.connectionError.set(true);
else location.reload();
if (!result) {
this.connectionError.set(true);
} else {
if (currentServer !== server.url) {
Cookies.remove("arcToken");
Cookies.remove("arcUsername");
localStorage.removeItem("arcLoginPersistence");
}

location.reload();
}
}

async removeServer(server: ServerOption) {
Expand Down