2022-08-01 21:08:34 +02:00
|
|
|
import { readable, type Readable } from "svelte/store";
|
2022-03-03 10:10:44 +01:00
|
|
|
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",
|
2022-03-20 11:21:36 +01:00
|
|
|
NUM_VISITED: "Times visited",
|
2022-03-03 10:10:44 +01:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|