From dfd3d6f37450726111c2f2bb1dfb5e61ddc33ffb Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Mon, 26 Aug 2024 16:38:29 +0200 Subject: [PATCH] work on childrendata skeleton --- src/lib/stores/childrenData.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/stores/childrenData.js b/src/lib/stores/childrenData.js index 3bbfe2a0..9bd570b0 100644 --- a/src/lib/stores/childrenData.js +++ b/src/lib/stores/childrenData.js @@ -4,8 +4,23 @@ let childrenlist = {}; const childrenData = writable(childrenlist); -function addChildrenData(data, usertoken) {} +async function addChildrenData(data, usertoken) { + childrenData.update((childrenlist) => { + if (usertoken in childrenlist) { + childrenlist[usertoken] = data; + } else { + childrenlist[usertoken] = {}; + childrenlist[usertoken][data.token] = data; + } + }); +} -function removeChildrenData(usertoken) {} +async function removeChildrenData(usertoken, childtoken) { + childrenData.update((childrenlist) => { + if (usertoken in childrenlist) { + delete childrenlist[usertoken][childtoken]; + } + }); +} export { addChildrenData, childrenData, removeChildrenData };