Skip to content

Commit 2ecf4f5

Browse files
Merge pull request #3688 from opral/lixdk-460-incremental
reduce change storage by 90%
2 parents 08ef3c6 + 0c3e83c commit 2ecf4f5

File tree

69 files changed

+10823
-3025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+10823
-3025
lines changed

packages/csv-app/src/components/ChangeSet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
createThread,
55
createCheckpoint,
66
Thread,
7-
Version,
7+
LixVersion,
88
} from "@lix-js/sdk";
99
import { useAtom } from "jotai";
1010
import { useCallback, useEffect, useState } from "react";
@@ -252,7 +252,7 @@ const getChanges = async (
252252
changeSetId: string,
253253
fileId: string,
254254
// @ts-expect-error - not used yet
255-
currentVersion: Version,
255+
currentVersion: LixVersion,
256256
previousChangeSetId?: string | undefined | null
257257
): Promise<
258258
Record<

packages/csv-app/src/layouts/OpenFileLayout.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import { useCallback, useMemo, useState } from "react";
2222
import { currentVersionAtom, existingVersionsAtom, lixAtom } from "../state.ts";
2323
import { saveLixToOpfs } from "../helper/saveLixToOpfs.ts";
2424
import clsx from "clsx";
25-
import {
26-
Version,
27-
createVersion,
28-
switchVersion,
29-
} from "@lix-js/sdk";
25+
import { LixVersion, createVersion, switchVersion } from "@lix-js/sdk";
3026
import CustomLink from "../components/CustomLink.tsx";
3127

3228
export default function Layout(props: { children: React.ReactNode }) {
@@ -221,7 +217,7 @@ const VersionDropdown = () => {
221217
const [lix] = useAtom(lixAtom);
222218

223219
const switchToversion = useCallback(
224-
async (version: Version) => {
220+
async (version: LixVersion) => {
225221
await switchVersion({ lix, to: version });
226222
await saveLixToOpfs({ lix });
227223
},

packages/csv-app/src/state.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
Account,
3-
Lix,
4-
Version,
5-
openLix,
6-
switchAccount,
7-
} from "@lix-js/sdk";
1+
import { Account, Lix, LixVersion, openLix, switchAccount } from "@lix-js/sdk";
82
import { atom } from "jotai";
93
import { plugin as csvPlugin } from "@lix-js/plugin-csv";
104
import { getOriginPrivateDirectory } from "native-file-system-adapter";
@@ -155,7 +149,7 @@ export const lixAtom = atom(async (get) => {
155149
});
156150

157151
export const currentVersionAtom = atom<
158-
Promise<Version & { targets: Version[] }>
152+
Promise<LixVersion & { targets: LixVersion[] }>
159153
>(async (get) => {
160154
get(withPollingAtom);
161155
const lix = await get(lixAtom);

packages/lix-file-manager/src/components/MergeDialog.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
DialogTitle,
77
DialogFooter,
88
} from "@/components/ui/dialog.js";
9-
import { Version } from "@lix-js/sdk";
9+
import { LixVersion } from "@lix-js/sdk";
1010
import {
1111
Select,
1212
SelectContent,
@@ -20,10 +20,10 @@ import { transition } from "@lix-js/sdk";
2020
interface MergeDialogProps {
2121
open: boolean;
2222
onOpenChange: (open: boolean) => void;
23-
versions: Version[];
24-
activeVersion: Version;
23+
versions: LixVersion[];
24+
activeVersion: LixVersion;
2525
lix: any;
26-
initialSourceVersion: Version | null;
26+
initialSourceVersion: LixVersion | null;
2727
onMergeComplete: () => void;
2828
}
2929

packages/lix-file-manager/src/components/VersionDropdown.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
isSyncingAtom,
2222
lixAtom,
2323
} from "../state.js";
24-
import { Version, createVersion, switchVersion } from "@lix-js/sdk";
24+
import { LixVersion, createVersion, switchVersion } from "@lix-js/sdk";
2525
import { saveLixToOpfs } from "../helper/saveLixToOpfs.js";
2626
import { Check, Trash2, ChevronDown, Plus } from "lucide-react";
2727
import { MergeDialog } from "./MergeDialog.js";
@@ -32,16 +32,18 @@ export function VersionDropdown() {
3232
const [existingVersions] = useAtom(existingVersionsAtom);
3333
const [lix] = useAtom(lixAtom);
3434
const [isSyncing] = useAtom(isSyncingAtom);
35-
const [versionToDelete, setVersionToDelete] = useState<Version | null>(null);
35+
const [versionToDelete, setVersionToDelete] = useState<LixVersion | null>(
36+
null
37+
);
3638
const [dropdownOpen, setDropdownOpen] = useState(false);
3739
const [deleteConfirmation, setDeleteConfirmation] = useState("");
3840
const [isHovered, setIsHovered] = useState(false);
3941
const [mergeDialogOpen, setMergeDialogOpen] = useState(false);
4042
const [selectedSourceVersion, setSelectedSourceVersion] =
41-
useState<Version | null>(null);
43+
useState<LixVersion | null>(null);
4244

4345
const switchToVersion = useCallback(
44-
async (version: Version) => {
46+
async (version: LixVersion) => {
4547
if (!lix) return;
4648
await switchVersion({ lix, to: version });
4749
await saveLixToOpfs({ lix });
@@ -60,7 +62,7 @@ export function VersionDropdown() {
6062
await switchToVersion(newVersion);
6163
}, [lix, activeVersion, switchToVersion]);
6264

63-
const handleDeleteVersion = async (version: Version) => {
65+
const handleDeleteVersion = async (version: LixVersion) => {
6466
if (!lix) return;
6567

6668
await lix.db.transaction().execute(async (trx) => {

packages/lix-file-manager/src/state.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
openLix,
3-
Account,
4-
switchAccount,
5-
Lix,
6-
Version,
7-
} from "@lix-js/sdk";
1+
import { openLix, Account, switchAccount, Lix, LixVersion } from "@lix-js/sdk";
82
import { atom } from "jotai";
93
import { plugin as csvPlugin } from "@lix-js/plugin-csv";
104
import { plugin as txtPlugin } from "@lix-js/plugin-txt";
@@ -211,19 +205,21 @@ export const lixAtom = atom(async (get) => {
211205
*/
212206
export const withPollingAtom = atom(Date.now());
213207

214-
export const activeVersionAtom = atom<Promise<Version | null>>(async (get) => {
215-
get(withPollingAtom);
216-
const lix = await get(lixAtom);
217-
if (!lix) return null;
208+
export const activeVersionAtom = atom<Promise<LixVersion | null>>(
209+
async (get) => {
210+
get(withPollingAtom);
211+
const lix = await get(lixAtom);
212+
if (!lix) return null;
218213

219-
const activeVersion = await lix.db
220-
.selectFrom("active_version")
221-
.innerJoin("version", "active_version.version_id", "version.id")
222-
.selectAll("version")
223-
.executeTakeFirstOrThrow();
214+
const activeVersion = await lix.db
215+
.selectFrom("active_version")
216+
.innerJoin("version", "active_version.version_id", "version.id")
217+
.selectAll("version")
218+
.executeTakeFirstOrThrow();
224219

225-
return activeVersion;
226-
});
220+
return activeVersion;
221+
}
222+
);
227223

228224
export const existingVersionsAtom = atom(async (get) => {
229225
get(withPollingAtom);

0 commit comments

Comments
 (0)