Some plumbing for local storage for apps.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3864 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-03-27 19:53:02 +00:00
parent a1d244567a
commit 42fcfee042
2 changed files with 7 additions and 1 deletions

View File

@ -418,6 +418,10 @@ function receive(message) {
}
}
console.log('error', message);
} else if (message && message.action == "localStorageSet") {
window.localStorage.setItem('app:' + message.key, message.value);
} else if (message && message.action == "localStorageGet") {
send({message: 'localStorage', key: message.key, value: window.localStorage.getItem('app:' + message.key)});
} else if (message && message.action == "print") {
console.log('app>', ...message.args);
} else if (message && message.action == "stats") {
@ -673,6 +677,8 @@ function connectSocket(path) {
['setDocument', 'content'],
['postMessage', 'message'],
['error', 'error'],
['localStorageSet', 'key', 'value'],
['localStorageGet', 'key'],
],
}));
}

View File

@ -159,7 +159,7 @@ async function getProcessBlob(blobId, key, options) {
}
process.eventHandlers[eventName].push(handler);
},
'unregister': function(eventHandle, handler) {
'unregister': function(eventName, handler) {
if (process.eventHandlers[eventName]) {
let index = process.eventHandlers[eventName].indexOf(handler);
if (index != -1) {