react-query-autosync
react-query-autosync copied to clipboard
saveStatus showing unsaved when status should be saved
Thanks for this great resource!
While I was using the useReactQueryAutoSync hook in my project, I noticed the saveStatus conditional returns unsaved when draft is really saved. I also noticed this wasn't working in the demo.
In useReactQueryAutoSync, onMutation in the useMutation hook will set the draft to undefined setDraft(undefined); after it is mutated. This results in the saveStatus value to equal 'unsaved' when it is really saved. Am I using this setStatus states correctly? If so, a suggestion is to add an or statement to saveStatus. ie for the last conditional:
queryResult.data === draft || draft === undefined ? 'saved' : 'unsaved'
Oh wow, thank you for the excellent bug report. Off the bat, I completely agree with your logic. Is this blocking your work? If so I'll try to release a tagged version you can use to unblock yourself. If not I may take a couple of days to release a new version since I want to review the logic before publishing a new release so that I can try to identify other similar bugs.
No rush, this is not blocking my work. I will let you know if I run into any similar bugs when I'm playing around as well. Thanks again for the resource and your quick reply!