async function database_list() {
var dbs = await databases();
var doc = `
Databases
`;
app.setDocument(doc);
}
async function key_list(db) {
let keys = await db.getAll();
let object = {};
for (let key of keys) {
object[key] = await db.get(key);
}
let doc = `
back
Keys
`;
app.setDocument(doc);
}
function load() {
if (core.user?.credentials?.session) {
database_list();
} else {
app.setDocument(`
Must be signed in to examine databases.
`);
}
}
core.register('message', async function (message) {
if (message.event == 'hashChange') {
let hash = message.hash.substring(1);
if (hash.startsWith(':shared:')) {
let parts = hash.split(':');
let packageName = parts[3];
let key = parts.slice(4).join(':');
key_list(await my_shared_database(packageName, key));
} else if (hash.length) {
key_list(await database(hash.split(':').slice(1).join(':')));
} else {
load();
}
}
});
load();