@xnetjs/react 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@ import {
15
15
  import { ExternalReferenceSchema, TaskSchema, isCompletedTaskStatus } from "@xnetjs/data";
16
16
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
17
17
  var DEFAULT_DEBOUNCE_MS = 250;
18
+ var UNTITLED_TASK_PLACEHOLDER = "Untitled task";
18
19
  function arraysEqual(a, b) {
19
20
  if (!Array.isArray(a)) return b.length === 0;
20
21
  if (a.length !== b.length) return false;
@@ -106,6 +107,7 @@ function useTaskProjectionSync({
106
107
  includeDeleted: true
107
108
  });
108
109
  const taskSnapshotsRef = useRef([]);
110
+ const snapshotHostRef = useRef(null);
109
111
  const syncRunIdRef = useRef(0);
110
112
  const [revision, setRevision] = useState(0);
111
113
  const [syncing, setSyncing] = useState(false);
@@ -113,12 +115,17 @@ function useTaskProjectionSync({
113
115
  const existingTaskMap = useMemo(() => {
114
116
  return new Map(existingTasks.map((task) => [task.id, task]));
115
117
  }, [existingTasks]);
116
- const handleTasksChange = useCallback((tasks) => {
117
- taskSnapshotsRef.current = tasks;
118
- setRevision((value) => value + 1);
119
- }, []);
118
+ const handleTasksChange = useCallback(
119
+ (tasks) => {
120
+ taskSnapshotsRef.current = tasks;
121
+ snapshotHostRef.current = hostId;
122
+ setRevision((value) => value + 1);
123
+ },
124
+ [hostId]
125
+ );
120
126
  useEffect(() => {
121
127
  if (!hostId) return;
128
+ if (snapshotHostRef.current !== hostId) return;
122
129
  let cancelled = false;
123
130
  const timer = setTimeout(() => {
124
131
  const run = async () => {
@@ -186,7 +193,10 @@ function useTaskProjectionSync({
186
193
  const updateData = {};
187
194
  const nextDueDate = dueDate;
188
195
  const nextPrimaryAssignee = primaryAssignee;
189
- if (existingTask.title !== task.title) updateData.title = task.title;
196
+ const placeholderOverRealTitle = task.title === UNTITLED_TASK_PLACEHOLDER && typeof existingTask.title === "string" && existingTask.title.length > 0;
197
+ if (existingTask.title !== task.title && !placeholderOverRealTitle) {
198
+ updateData.title = task.title;
199
+ }
190
200
  if (existingTask.completed !== task.completed) updateData.completed = task.completed;
191
201
  if (existingTask.status !== nextStatus) updateData.status = nextStatus;
192
202
  if ((existingTask.parent ?? null) !== task.parentTaskId) {
@@ -257,7 +267,13 @@ function useTaskProjectionSync({
257
267
  }
258
268
  if (cancelled || runId !== syncRunIdRef.current) return;
259
269
  if (claimed) {
260
- await update(TaskSchema, task.id, task.data);
270
+ if (task.data.title === UNTITLED_TASK_PLACEHOLDER) {
271
+ const dataWithoutTitle = { ...task.data };
272
+ delete dataWithoutTitle.title;
273
+ await update(TaskSchema, task.id, dataWithoutTitle);
274
+ } else {
275
+ await update(TaskSchema, task.id, task.data);
276
+ }
261
277
  } else {
262
278
  await create(TaskSchema, task.data, task.id);
263
279
  }
@@ -73,7 +73,7 @@ import {
73
73
  useUndo,
74
74
  useVerification,
75
75
  useVisibleComments
76
- } from "./chunk-QIX3F46C.js";
76
+ } from "./chunk-SEYIZDHG.js";
77
77
  import {
78
78
  flattenNode,
79
79
  flattenNodes,
package/dist/index.js CHANGED
@@ -94,7 +94,7 @@ import {
94
94
  useUndo,
95
95
  useVerification,
96
96
  useVisibleComments
97
- } from "./chunk-QIX3F46C.js";
97
+ } from "./chunk-SEYIZDHG.js";
98
98
  import {
99
99
  EMPTY_PAGE_INFO,
100
100
  computeFallbackPageInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnetjs/react",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,15 +46,15 @@
46
46
  "y-protocols": "^1.0.6",
47
47
  "yjs": "^13.6.24",
48
48
  "@xnetjs/billing": "0.0.2",
49
- "@xnetjs/core": "0.8.0",
50
- "@xnetjs/crypto": "0.8.0",
51
- "@xnetjs/data-bridge": "0.8.0",
52
- "@xnetjs/data": "0.8.0",
53
- "@xnetjs/history": "0.8.0",
54
- "@xnetjs/identity": "0.8.0",
55
- "@xnetjs/plugins": "0.8.0",
56
- "@xnetjs/runtime": "0.2.0",
57
- "@xnetjs/sync": "0.8.0"
49
+ "@xnetjs/core": "0.10.0",
50
+ "@xnetjs/crypto": "0.10.0",
51
+ "@xnetjs/data": "0.10.0",
52
+ "@xnetjs/data-bridge": "0.10.0",
53
+ "@xnetjs/history": "0.10.0",
54
+ "@xnetjs/identity": "0.10.0",
55
+ "@xnetjs/plugins": "0.10.0",
56
+ "@xnetjs/runtime": "0.2.2",
57
+ "@xnetjs/sync": "0.10.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.0.0 || ^19.0.0"