From 42fcfee042223cb2ff0187829840064d7d7f61e1 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 27 Mar 2022 19:53:02 +0000 Subject: [PATCH] Some plumbing for local storage for apps. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3864 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/client.js | 6 ++++++ core/core.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/client.js b/core/client.js index bfa97274..adf57494 100644 --- a/core/client.js +++ b/core/client.js @@ -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'], ], })); } diff --git a/core/core.js b/core/core.js index a55a92aa..6eaea5c3 100644 --- a/core/core.js +++ b/core/core.js @@ -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) {