1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-16 13:04:06 +00:00

Frontend reorganisation

This commit is contained in:
2023-02-14 17:51:00 +01:00
parent f606a4807c
commit 3291bc845f
31 changed files with 165 additions and 148 deletions

View File

@ -0,0 +1,36 @@
import { get, writable } from 'svelte/store';
import { UpdateViewStore, Views } from '../../../wailsjs/go/app/App';
const { set, subscribe } = writable({});
let skipUpdate = true;
async function reload() {
const newViewStore = await Views();
set(newViewStore);
return newViewStore;
}
function forCollection(hostKey, dbKey, collKey) {
const allViews = get({ subscribe });
const entries = Object.entries(allViews).filter(v => (
v[0] === 'list' || (
v[1].host === hostKey &&
v[1].database === dbKey &&
v[1].collection === collKey
)
));
return Object.fromEntries(entries);
}
reload();
subscribe(newViewStore => {
if (skipUpdate) {
skipUpdate = false;
return;
}
UpdateViewStore(JSON.stringify(newViewStore));
});
const views = { reload, set, subscribe, forCollection };
export default views;