This commit is contained in:
Chris Kruining 2025-02-04 15:50:11 +11:00
parent 9ace9b9f4f
commit fc4109ad45
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
2 changed files with 4 additions and 10 deletions

View file

@ -164,11 +164,6 @@ export const createDataSet = <T extends Record<string, any>>(data: Accessor<T[]>
setState('value', nextValue);
setState('snapshot', next);
;
});
createEffect(() => {
console.log('dataset', mutations());
});
const set: DataSet<T> = {

View file

@ -107,21 +107,22 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
return mutations.flatMap((m): any => {
const [index, lang] = splitAt(m.key, m.key.indexOf('.'));
const file = files.get(lang);
switch (m.kind) {
case MutarionKind.Update: {
const entry = entries.get(index as any)!;
return { kind: MutarionKind.Update, key: entry.key, lang, file: files.get(lang)!, value: m.value };
return { kind: MutarionKind.Update, key: entry.key, lang, file, value: m.value };
}
case MutarionKind.Create: {
if (typeof m.value === 'object') {
const { key, ...locales } = m.value;
return Object.entries(locales).map(([lang, value]) => ({ kind: MutarionKind.Create, key, lang, file: files.get(lang)!, value }));
return Object.entries(locales).map(([lang, value]) => ({ kind: MutarionKind.Create, key, lang, file, value }));
}
const entry = entries.get(index as any)!;
return { kind: MutarionKind.Create, key: entry.key, lang, file: files.get(lang), value: m.value };
return { kind: MutarionKind.Create, key: entry.key, lang, file, value: m.value };
}
case MutarionKind.Delete: {
@ -146,8 +147,6 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
}
const groupedByFileId = Object.groupBy(muts, m => m.file?.id ?? 'undefined');
console.log(files, muts, groupedByFileId);
const newFiles = Object.entries(Object.groupBy((groupedByFileId['undefined'] ?? []) as (Created & { lang: string, file: undefined })[], m => m.lang)).map(([lang, mutations]) => {
const data = mutations!.reduce((aggregate, { key, value }) => {
let obj = aggregate;