@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(
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/experimental.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnetjs/react",
|
|
3
|
-
"version": "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.
|
|
50
|
-
"@xnetjs/crypto": "0.
|
|
51
|
-
"@xnetjs/data
|
|
52
|
-
"@xnetjs/data": "0.
|
|
53
|
-
"@xnetjs/history": "0.
|
|
54
|
-
"@xnetjs/identity": "0.
|
|
55
|
-
"@xnetjs/plugins": "0.
|
|
56
|
-
"@xnetjs/runtime": "0.2.
|
|
57
|
-
"@xnetjs/sync": "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"
|