clean up
This commit is contained in:
parent
9ace9b9f4f
commit
fc4109ad45
2 changed files with 4 additions and 10 deletions
|
@ -164,11 +164,6 @@ export const createDataSet = <T extends Record<string, any>>(data: Accessor<T[]>
|
||||||
|
|
||||||
setState('value', nextValue);
|
setState('value', nextValue);
|
||||||
setState('snapshot', next);
|
setState('snapshot', next);
|
||||||
;
|
|
||||||
});
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
console.log('dataset', mutations());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const set: DataSet<T> = {
|
const set: DataSet<T> = {
|
||||||
|
|
|
@ -107,21 +107,22 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
|
||||||
|
|
||||||
return mutations.flatMap((m): any => {
|
return mutations.flatMap((m): any => {
|
||||||
const [index, lang] = splitAt(m.key, m.key.indexOf('.'));
|
const [index, lang] = splitAt(m.key, m.key.indexOf('.'));
|
||||||
|
const file = files.get(lang);
|
||||||
|
|
||||||
switch (m.kind) {
|
switch (m.kind) {
|
||||||
case MutarionKind.Update: {
|
case MutarionKind.Update: {
|
||||||
const entry = entries.get(index as any)!;
|
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: {
|
case MutarionKind.Create: {
|
||||||
if (typeof m.value === 'object') {
|
if (typeof m.value === 'object') {
|
||||||
const { key, ...locales } = m.value;
|
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)!;
|
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: {
|
case MutarionKind.Delete: {
|
||||||
|
@ -146,8 +147,6 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupedByFileId = Object.groupBy(muts, m => m.file?.id ?? 'undefined');
|
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 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 }) => {
|
const data = mutations!.reduce((aggregate, { key, value }) => {
|
||||||
let obj = aggregate;
|
let obj = aggregate;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue