opral / lix-sdk

1 stars 0 forks source link

Initial data is not producing changes #33

Closed NilsJacobsen closed 1 month ago

NilsJacobsen commented 1 month ago

In the FinkV2 app I have a import button. This import inserts a nested bundle by iterating over bundles, messages and variants. I expect it to generate a change per entry.

It is successfully insterted in the db also opfs, but doesn't generate entries in the changes table.

import { useState } from "react";
import { SlButton, SlDialog } from "@shoelace-style/shoelace/dist/react";
import { projectAtom } from "./../state.ts";
import { useAtom } from "jotai";
import { demoBundles } from "./../../demo/bundles.ts";
import { insertBundleNested } from "@inlang/sdk2";

const ImportComponent = () => {
    const [showDialog, setShowDialog] = useState(false);
    const [loading, setLoading] = useState(false);
    const [project] = useAtom(projectAtom);

    const handleImport = async () => {
        if (project) {
            setLoading(true);
            for (const bundle of demoBundles) {
                await insertBundleNested(project.db, bundle);
            }

            setLoading(false);
            setShowDialog(false);
        }
    };

    return (
        <>
            <SlButton
                size="small"
                onClick={() => {
                    setShowDialog(true);
                }}
            >
                Import
            </SlButton>
            <SlDialog
                label="Import Translations"
                open={showDialog}
                onSlRequestClose={() => setShowDialog(false)}
            >
                <SlButton
                    loading={loading}
                    variant="primary"
                    slot="footer"
                    onClick={handleImport}
                >
                    Import demo bundles
                </SlButton>
            </SlDialog>
        </>
    );
};

export default ImportComponent;

Could the problem origin from lix?

samuelstroschein commented 1 month ago

will look into this now that jan's state is operating on the same branch

samuelstroschein commented 1 month ago

closed by https://github.com/opral/monorepo/pull/3059#discussion_r1715330278