Skip to content

Commit

Permalink
Assistant can start local apps
Browse files Browse the repository at this point in the history
  • Loading branch information
datkat21 committed Mar 25, 2024
1 parent 6f5445d commit 4431392
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions pkgs/lib/Assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ function replace(str, u) {
}

async function ask(what) {
const vfs = await lib.loadLibrary("VirtualFS");

// get all apps
what = what
.toLowerCase()
Expand Down Expand Up @@ -462,11 +464,27 @@ async function ask(what) {
case "startPkg":
if (data.app === undefined)
return { type: "response", text: "I don't know what app to launch." };
if (data.app.mapping === null)
return {
type: "response",
text: `I am unable to start ${data.app.name}.`,
};
if (data.app.mapping === null) {
if (data.app.source === "local") {
const appPath = "Root/Pluto/apps/" + data.app.name;
let appName = data.app.name.split(".");

appName.pop();
appName = appName.join(".");

core.startPkg(
"data:text/javascript," +
encodeURIComponent(await vfs.readFile(appPath)),
false,
false
);
return {
type: "response",
text: `Launching local app ${appName}.`,
};
}
}

await data.app.mapping.onClick(core);

return {
Expand Down

0 comments on commit 4431392

Please sign in to comment.