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

Warn users when before signing out with unsynced notes #702

Merged
merged 10 commits into from
Feb 7, 2018

Conversation

roundhill
Copy link
Contributor

Some users are losing notes when they sign out because for one reason or another they have unsynced notes. This is a quick solution to that which searches for unsynced notes upon signout and warns the user if so. An option is presented to view the web app to reconcile their unsynced notes:

Windows/Linux:
screen shot 2018-01-29 at 4 01 46 pm
screen shot 2018-01-29 at 3 53 33 pm

On the web (currently not used in production), a humble confirm dialog is displayed:
screen shot 2018-01-29 at 4 04 50 pm

One nice thing that we could also do is offer to export the notes for the user. Maybe in place of the 'Visit Web App' button?

To Test

  • Take the app offline, and create a note.
  • Click Simplenote menu and then Sign Out. You should see the alert dialog.
  • Verify all of the buttons work as expected.
  • Also verify that you don't see the prompt if all of your notes have synced.

Refs: Automattic/Simplenote-United#7

@roundhill
Copy link
Contributor Author

Noticed that I said Signing out in the screenshots, it should be Logging out. Corrected in
7492903

@roundhill
Copy link
Contributor Author

One other thing to note, the iOS and macOS PRs also check for notes with queued changes that haven't synced yet. I haven't dug into whether or not we can do that with node-simperium for this PR .

@roundhill
Copy link
Contributor Author

roundhill commented Feb 7, 2018

One other thing to note, the iOS and macOS PRs also check for notes with queued changes that haven't synced yet.

@beaucollins helped me get a check for this added to node-simperium as well 👍 It now also checks for queued local changes.

@dmsnell could you have a look a this one at your convenience? 🙏

() => this.showUnsyncedWarning() // Show a warning to the user
);
})
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's going on here? is there a missing if statement body? something is wrong.

Copy link
Contributor Author

@roundhill roundhill Feb 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I had an if there that didn't belong. Callbacks are silly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 looks better now

getVersion(note.id, (e, v) => (e || v === 0 ? reject() : resolve()))
);

Promise.race(notes.map(noteHasSynced)).then(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be Promise.all not Promise.race? You want to make sure that none of the notes are unsynced right?

getVersion(note.id, (e, v) => (e || v === 0 ? reject() : resolve()))
);

Promise.race(notes.map(noteHasSynced)).then(
Copy link
Contributor

@beaucollins beaucollins Feb 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I commented on an outdated change but the Promise.race remains.

It seems you want to check if any of the notes have a version of 0 and if any of them do have a version of 0 then you will want to show showUnsyncedWarning.

Promise.race will return the first promise that resolves or rejects and ignore all others where as Promise.all will wait until all Promises resolve or fail early upon the first reject.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ok, I think I indeed want Promise.all then. If we ever see a version of zero we should stop and show the warning. Otherwise, keep checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 5324686. Nice catch!

Copy link
Member

@dmsnell dmsnell Feb 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch @beaucollins - the race was from my original idea where only the unsync'd notes would resolve and so we wouldn't have needed to wait for all Promises - an early abort. this was a wrong idea. 😄

it would also work if we only reject()ed on unsync'd notes and had a timeout, but that's another kind of race we don't want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've learned a lot about Promise via this PR! :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roundhill you don't need to learn that much about promises. just let your "yes" be "yes" and your "no" be "no" 😉

@roundhill roundhill merged commit 5e78ca0 into master Feb 7, 2018
@roundhill roundhill deleted the add/signout-unsynced-prompt branch February 7, 2018 17:23
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

Successfully merging this pull request may close these issues.

3 participants