Skip to content

Commit

Permalink
introduce scuffed way in order to make create server button work again
Browse files Browse the repository at this point in the history
  • Loading branch information
GregTCLTK committed Nov 2, 2023
1 parent 986e733 commit 5fb91da
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"imports": {
"webgen/": "https://raw.githubusercontent.com/lucsoft/WebGen/a23b2fb/",
// "webgen/": "../WebGen/",
"std/": "https://deno.land/std@0.204.0/",
"std/": "https://deno.land/std@0.205.0/",
"shared": "./pages/shared/mod.ts"
},
"compilerOptions": {
Expand Down
7 changes: 1 addition & 6 deletions pages/hosting/data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { State } from "webgen/mod.ts";
import { Meta, Server, ServerTypes } from "../../spec/music.ts";

export const MB = 1000_000;
export const MB = 1000000;

export const state = State({
loaded: false,
Expand All @@ -13,9 +13,4 @@ export const creationState = State({
loading: false,
type: <ServerTypes | undefined>undefined,
versions: <string[]>[]
});

export const detailsState = State({
loaded: false,
server: <Server | undefined>undefined,
});
15 changes: 4 additions & 11 deletions pages/hosting/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ WebGen({
View(() => Vertical(DynaNavigation("Hosting"), state.$loaded.map(loaded => loaded ? hostingMenu : LoadingSpinner()).asRefComponent())).appendOn(document.body);

renewAccessTokenIfNeeded()
.then(() => refreshState())
.then(async () => {
if (!urlPath) {
await refreshState();
state.loaded = true;
return;
} else {
state.meta = State(await API.hosting.meta());
if (urlPath) {
const [ source, serverId, subView ] = urlPath.split("/");
if (source === "servers" && serverId) {
const server = await API.hosting.serverId(serverId).get().then(stupidErrorAlert);
refreshState();
state.servers.push(State(server));
await streamingPool();
if (!server.identifier)
Expand All @@ -44,11 +39,9 @@ renewAccessTokenIfNeeded()
await listFiles("/");
path.setValue("/");
}
} else {
await refreshState();
}
hostingMenu.path.setValue(urlPath);
state.loaded = true;
}
})
.then(() => listener());
.then(() => listener())
.then(() => state.loaded = true);
34 changes: 18 additions & 16 deletions pages/hosting/views/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,24 @@ export const hostingMenu = Navigation({
"limited-width"
);

hostingMenu.path.listen(path => {
if ([ "servers/", "resources/" ].includes(path)) {
hostingButtons.setValue(
[
Button("Start new Server")
.setColor(state.$meta.map(meta => !meta || (meta.used.slots >= meta.limits.slots) ? Color.Disabled : Color.Grayscaled))
.onClick(() => {
location.href = "/hosting/create";
})
]
);
stopSidecarConnection();
}
else
hostingButtons.setValue([]);
});
state.$meta.listen(() =>
hostingMenu.path.listen(path => {
if ([ "servers/", "resources/" ].includes(path)) {
hostingButtons.setValue(
[
Button("Start new Server")
.setColor(state.$meta.map(meta => !meta || (meta.used.slots >= meta.limits.slots) ? Color.Disabled : Color.Grayscaled))
.onClick(() => {
location.href = "/hosting/create";
})
]
);
stopSidecarConnection();
}
else
hostingButtons.setValue([]);
})
);

let firstRouteChange = false;
hostingMenu.path.listen(path => {
Expand Down

0 comments on commit 5fb91da

Please sign in to comment.