mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-25 03:25:56 +00:00
Let players download and update clients without a local server
This commit is contained in:
1 parent
e8367354ef
commit
c39a7a0ac7
18 files changed
+406
-49
No files matched your search
+17
-2
@@ -4,14 +4,20 @@ import { Welcome } from "@/screens/Welcome";
|
||||
import { ImportServer } from "@/screens/ImportServer";
|
||||
import { Shell } from "@/screens/Shell";
|
||||
import { InstallServer } from "@/screens/InstallServer";
|
||||
import { RemoteClient } from "@/screens/RemoteClient";
|
||||
import { UpdateBanner } from "@/components/UpdateBanner";
|
||||
import { autoUpdateEnabled, installOnClose, lookForUpdate } from "@/lib/selfUpdate";
|
||||
|
||||
type View = "welcome" | "add" | "import" | "install";
|
||||
type View = "welcome" | "add" | "import" | "install" | "remote";
|
||||
|
||||
function initialView(): View {
|
||||
try { return localStorage.getItem("coa-play-mode") === "remote" ? "remote" : "welcome"; }
|
||||
catch { return "welcome"; }
|
||||
}
|
||||
|
||||
function Main() {
|
||||
const [servers, setServers] = useState<ServerSummary[] | null>(null);
|
||||
const [view, setView] = useState<View>("welcome");
|
||||
const [view, setView] = useState<View>(initialView);
|
||||
const [activeId, setActiveId] = useState<string | null>(null);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
@@ -26,6 +32,11 @@ function Main() {
|
||||
|
||||
if (servers === null) return null;
|
||||
|
||||
if (view === "remote") return <RemoteClient onHost={() => {
|
||||
try { localStorage.setItem("coa-play-mode", "host"); } catch { /* storage unavailable */ }
|
||||
setView(servers.length ? "welcome" : "add");
|
||||
}} />;
|
||||
|
||||
if (servers.length > 0 && view === "welcome" && activeId) {
|
||||
return (
|
||||
<Shell
|
||||
@@ -71,6 +82,10 @@ function Main() {
|
||||
|
||||
return (
|
||||
<Welcome
|
||||
onConnect={() => {
|
||||
try { localStorage.setItem("coa-play-mode", "remote"); } catch { /* storage unavailable */ }
|
||||
setView("remote");
|
||||
}}
|
||||
onImport={() => setView("import")}
|
||||
onInstall={() => setView("install")}
|
||||
onBack={servers.length > 0 ? () => setView("welcome") : undefined}
|
||||
|
||||
Reference in new issue
Block a user