Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Area lost on update #1

Closed
holman opened this issue Apr 12, 2010 · 4 comments
Closed

Area lost on update #1

holman opened this issue Apr 12, 2010 · 4 comments

Comments

@holman
Copy link

holman commented Apr 12, 2010

area = Things::Area.find('Existing Area')
todo = Things::Todo.new('New Todo')
todo.area = area
todo.save

This correctly sets up "New Todo" inside of "Existing Area". But then:

todo = Things::Todo.find('New Todo')
todo.area = area # area is now properly assigned in-memory
todo.save

I can see Things flicker as it adds "New Todo" inside of "Existing Area", but immediately it reassigns it to a nil area (ie, re-finding the todo and calling #area on it returns nil).

Looks like the library's properly setting the area in creation, and possibly doing it correctly in update (the AppleScript references get passed correctly in Things::Reference::Record L72)- have you run into this at all before? Maybe just an irritating Things bug?

@holman
Copy link
Author

holman commented Apr 12, 2010

As another note: if I explicitly try to set it after save, all good:

todo.save # oh noes :(
todo.reference.area.set(area.reference) # oh word! :)

@applicake
Copy link

just noticed this issue, I'll take a look after work

@marcinbunsch
Copy link
Owner

First of all, massive thanks for playing with this code and finding the bug.

The bug was caused by a specific behavior of Things - when a Todo was saved without a project, Things moved it to the Next list and removed the area. I've corrected it by doing 2 things:

  1. When you save an object with an empty property (like project) the reference does not receive a delete call on that property if the property on the reference is also empty (so no real change was done - Things interpreted this as a false removal)
  2. I've moved the area property to the end of the update list, so even if you remove a todo from a project the area is maintained.

Hope that fixes the issue on your end too :)

@holman
Copy link
Author

holman commented Apr 22, 2010

Awesome; looks pretty good. I'll give it a try shortly, make sure it works in my setup, and update this if I run into any more troubles. Cheers, by the way; really well-designed library you've got here.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants