You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
When a task is created on the client, two messages are sent to the server: list.update and task.create.
list.update({"id": "inbox","tasks": ["c0"]},{"tasks": 1390074290378})task.create({"id": "c0","listId": "inbox","date": 0,"name": "This is a new task","notes": "","priority": 1,"completed": 0},1390074290379).fn(2)
See the problem? The inbox list has two tasks assigned to it: "c0" and "s1". But "c0" doesn't even exist!
Possible Solution 1
Whenever a list is created or updated, we loop through the tasks array and throw array any IDs that don't exist on the server.
The client sends the list.update message.
Server inspects the tasks property and deletes "c0" property.
The client sends the task.create message.
Server adds task ID to the tasks array.
Possible Solution 2
The client sends the task.create message first, and then waits for the server to return the server ID.
The server will automatically add the task into the list.
The client will then add the task into the list, and send the list.update event.
The server will then magically merge the tasks property.
Keeping Order
One of the features on the client is that you can sort tasks in order you want. We need to be able to keep this order on the server.
All The Solutions
So I think the best thing to do is just let the server manage the tasks array for each list.
Creating a task
The task.create event requires you send id and listId. The server can then check that listId exists, and will add the task id to it.
Moving a task between lists
Use task.update and set the listId to the new list id. The server can remove the task id from the old list and add it to the new one.
Destroying a task
Use task.destroy. The server can remove the task id from the list it was in.
Reordering a task
Send list.update with the tasks array.
The server willl throw array any tasks that don't exist on the server and add the tasks that aren't included. Then it will merge the order with the existing tasks array.
The text was updated successfully, but these errors were encountered:
Problem
When a task is created on the client, two messages are sent to the server:
list.update
andtask.create
.The server then stores the following.
See the problem? The inbox list has two tasks assigned to it:
"c0"
and"s1"
. But"c0"
doesn't even exist!Possible Solution 1
Whenever a list is created or updated, we loop through the tasks array and throw array any IDs that don't exist on the server.
list.update
message.tasks
property and deletes"c0"
property.task.create
message.tasks
array.Possible Solution 2
task.create
message first, and then waits for the server to return the server ID.list.update
event.tasks
property.Keeping Order
One of the features on the client is that you can sort tasks in order you want. We need to be able to keep this order on the server.
All The Solutions
So I think the best thing to do is just let the server manage the
tasks
array for each list.Creating a task
The
task.create
event requires you sendid
andlistId
. The server can then check thatlistId
exists, and will add the task id to it.Moving a task between lists
Use
task.update
and set thelistId
to the new list id. The server can remove the task id from the old list and add it to the new one.Destroying a task
Use
task.destroy
. The server can remove the task id from the list it was in.Reordering a task
Send
list.update
with the tasks array.The server willl throw array any tasks that don't exist on the server and add the tasks that aren't included. Then it will merge the order with the existing tasks array.
The text was updated successfully, but these errors were encountered: