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 };