Skip to content

Commit

Permalink
WIP - less base_index
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Sep 26, 2024
1 parent 75fd4ed commit 5eae808
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 32 deletions.
7 changes: 0 additions & 7 deletions pkg/shell/base_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ function Index() {
return false;
};

self.start = function() {
};

self.ready = function () {
window.addEventListener("popstate", ev => {
console.log("POP!");
Expand All @@ -116,10 +113,6 @@ function Index() {
cockpit.translate();
document.body.removeAttribute("hidden");
};

self.expect_restart = function (host) {
self.dispatchEvent("expect_restart", host);
};
}

function CompiledComponents() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/shell/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ export function Router(callbacks) {
cockpit.transport.inject(data, true);
}

self.start = function start() {
window.addEventListener("message", message_handler, false);
};

self.hint = function hint(name, data) {
const source = source_by_name[name];
/* This is often invalid when the window is closed */
Expand All @@ -291,4 +287,8 @@ export function Router(callbacks) {
if (source)
unregister(source);
};

cockpit.transport.wait(function() {
window.addEventListener("message", message_handler, false);
});
}
24 changes: 3 additions & 21 deletions pkg/shell/state.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ export function ShellState(trigger_connection_flow) {
const watchdog_problem = options.problem || "disconnected";
console.warn("transport closed: " + watchdog_problem);
self.problem = watchdog_problem;
update();
// We might get here real early, before events seem to
// work. Let's push the update processing to the event loop.
setTimeout(() => update(), 0);
});

const old_onerror = window.onerror;
Expand Down Expand Up @@ -426,22 +428,6 @@ export function ShellState(trigger_connection_flow) {
const index = base_index.new_index_from_proto(index_options);
self.index = index;

/* Restarts */
index.addEventListener("expect_restart", (ev, host) => loader.expect_restart(host));

/* Disconnection Dialog */
index.addEventListener("disconnect", (ev, problem) => {
self.problem = problem;
// XXX - If this happens very early, we need to push the
// signal emission to the event loop. Otherwise it gets
// ignored somehow...
setTimeout(() => update(), 0);
});

index.addEventListener("update", () => {
update();
});

function preload_host_frames (machine, manifests) {
const compiled = compile(machine);
for (const c in manifests) {
Expand Down Expand Up @@ -600,10 +586,6 @@ export function ShellState(trigger_connection_flow) {
return compiled;
}

cockpit.transport.wait(function() {
router.start();
});

self.last_path_for_host = (host) => {
return index.last_path_for_host[host];
};
Expand Down

0 comments on commit 5eae808

Please sign in to comment.