Skip to content

Commit

Permalink
use useY hook
Browse files Browse the repository at this point in the history
  • Loading branch information
nikgraf committed Jun 22, 2024
1 parent b56b324 commit 32d93a5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 59 deletions.
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-web": "~0.19.10",
"react-yjs": "^0.0.3",
"secsync": "^0.5.0",
"secsync-react-yjs": "^0.5.0",
"tailwind-merge": "^2.3.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/components/document.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useRef, useState } from "react";
import { View } from "react-native";
import sodium, { KeyPair } from "react-native-libsodium";
import { useY } from "react-yjs";
import { generateId } from "secsync";
import { useYjsSync } from "secsync-react-yjs";
import * as Yjs from "yjs";
Expand All @@ -12,7 +13,6 @@ import { Checkbox } from "../components/checkbox";
import { DocumentMembers } from "../components/documentMember";
import { SubtleInput } from "../components/subtleInput";
import { UpdateDocumentNameForm } from "../components/updateDocumentNameForm";
import { useYData } from "../hooks/useYData";
import { convertChecklistToArrayAndSort } from "../utils/convertChecklistToArrayAndSort";
import { deserialize } from "../utils/deserialize";
import { getDocumentStorage } from "../utils/documentStorage";
Expand Down Expand Up @@ -72,7 +72,7 @@ const Document: React.FC<Props> = ({ documentKey, documentId }) => {
}, []);

const yDocument: Yjs.Map<Yjs.Map<any>> = yDocRef.current.getMap("document");
const document = useYData<{ [k: string]: ChecklistItem }>(yDocument);
const document = useY(yDocument);
const checklist = document ? convertChecklistToArrayAndSort(document) : [];
const [newTodoText, setNewTodoText] = useState("");

Expand Down
24 changes: 0 additions & 24 deletions apps/app/src/hooks/useYArray.ts

This file was deleted.

26 changes: 0 additions & 26 deletions apps/app/src/hooks/useYData.ts

This file was deleted.

28 changes: 21 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32d93a5

Please sign in to comment.