X-Git-Url: https://git.r.bdr.sh/rbdr/forum/blobdiff_plain/bd8e98d7e24c4dbaee7db6ec7955f7c2f6d396a6..2a37b2ec11c46fc87dae084bc0a7659b198311aa:/src/stores/forums.js?ds=inline diff --git a/src/stores/forums.js b/src/stores/forums.js index e7acb60..583b0d3 100644 --- a/src/stores/forums.js +++ b/src/stores/forums.js @@ -1,36 +1,4 @@ -import { readable } from 'svelte/store'; +import { store } from './apollo'; +import { GET_FORUMS } from '$/data/queries'; -const internals = { - - // Constants - - kChangeFeedEventName: 'changefeed:forums', - - // The exported data structure - - forums: [], - - // Handles messages from the event - - handleChangeFeed(data) { - - // No old value == add - if (!data.old_val) { - return internals.forums.push(data.new_val); - } - - // We have an old value, let's find it. - const index = internals.forums.findIndex((element) => element.id === data.old_val.id); - - if (index > -1) { - if (data.new_val) { - return internals.forums.splice(index, 1, data.new_val || undefined); - } - - return internals.forums.splice(index, 1); - } - } -}; - -export const forums = readable(internals.forums, (set) => { -}); +export const forums = store({ key: 'forums', query: GET_FORUMS, initialValue: [] });