react-query-autosync icon indicating copy to clipboard operation
react-query-autosync copied to clipboard

saveStatus showing unsaved when status should be saved

Open sfisher4 opened this issue 3 years ago • 2 comments
trafficstars

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'

sfisher4 avatar Jun 27 '22 21:06 sfisher4

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.

lukesmurray avatar Jun 29 '22 00:06 lukesmurray

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!

sfisher4 avatar Jun 30 '22 14:06 sfisher4