Fix logout & clean command
This commit is contained in:
@@ -334,6 +334,17 @@ export function confirm(
|
||||
return syscall("editor.confirm", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user for confirmation
|
||||
* @param message the message to show in the confirmation dialog
|
||||
* @returns
|
||||
*/
|
||||
export function alert(
|
||||
message: string,
|
||||
): Promise<boolean> {
|
||||
return syscall("editor.alert", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a UI option
|
||||
* @param key the key of the UI option to get
|
||||
|
||||
@@ -10,5 +10,5 @@ export async function cleanCommand() {
|
||||
}
|
||||
await editor.flashNotification("Now wiping all state and logging out...");
|
||||
await debug.cleanup();
|
||||
await editor.openUrl("/.logout", true);
|
||||
await editor.alert("Cleanup done. Please close this window.");
|
||||
}
|
||||
|
||||
+8
-11
@@ -47,25 +47,22 @@ export function debugSyscalls(client: Client): SysCallMapping {
|
||||
location.reload();
|
||||
},
|
||||
"debug.cleanup": async () => {
|
||||
if (client.spaceKV) {
|
||||
console.log("Wiping the entire space KV store");
|
||||
// In sync mode, we can just delete the whole space
|
||||
const allKeys: KvKey[] = [];
|
||||
for await (const { key } of client.spaceKV.query({})) {
|
||||
allKeys.push(key);
|
||||
}
|
||||
await client.spaceKV.batchDelete(allKeys);
|
||||
console.log("Wiping the entire space KV store");
|
||||
// In sync mode, we can just delete the whole space
|
||||
let allKeys: KvKey[] = [];
|
||||
for await (const { key } of client.spaceKV.query({})) {
|
||||
allKeys.push(key);
|
||||
}
|
||||
await client.spaceKV.batchDelete(allKeys);
|
||||
localStorage.clear();
|
||||
console.log("Wiping the entire state KV store");
|
||||
const allKeys: KvKey[] = [];
|
||||
allKeys = [];
|
||||
for await (
|
||||
const { key } of await client.stateDataStore.luaQuery([], {})
|
||||
const { key } of client.stateDataStore.kv.query({})
|
||||
) {
|
||||
allKeys.push(key);
|
||||
}
|
||||
await client.stateDataStore.batchDelete(allKeys);
|
||||
console.log("Done");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -348,6 +348,9 @@ export function editorSyscalls(client: Client): SysCallMapping {
|
||||
"editor.confirm": (_ctx, message: string): Promise<boolean> => {
|
||||
return client.confirm(message);
|
||||
},
|
||||
"editor.alert": (_ctx, message: string) => {
|
||||
alert(message);
|
||||
},
|
||||
"editor.getUiOption": (_ctx, key: string): any => {
|
||||
return (client.ui.viewState.uiOptions as any)[key];
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user