import { readable, Readable } from "svelte/store"; import { fetchAllAttributes } from "../lib/api"; const DEFAULT_ATTRIBUTE_LABELS = { FILE_MIME: "MIME type", FILE_MTIME: "Last modified", FILE_SIZE: "File size", ADDED: "Added at", LAST_VISITED: "Last visited at", LBL: "Label", IS: "Type", }; export const attributeLabels: Readable<{ [key: string]: string }> = readable( DEFAULT_ATTRIBUTE_LABELS, (set) => { const result = Object.assign(DEFAULT_ATTRIBUTE_LABELS); fetchAllAttributes().then((attributes) => { attributes.forEach((attribute) => { if (attribute.labels.length) { result[attribute.name] = attribute.labels.sort()[0]; } }); set(result); }); } );