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

Notifications: contextualize email notifications #327

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented May 15, 2020

Stub/spike of moving the email notifications information up to a context.

@sohkai sohkai requested a review from rperez89 May 15, 2020 20:28
@vercel
Copy link

vercel bot commented May 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

if (!asyncCancelled.current) {
setEmail(email)
if (needsSignature !== Boolean(response.needsSignature)) {
setNeedsSignature(!needsSignature)
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to figure out how are you thinking to handle the action after the signature? i mean after the signature is successful we need to call again the subscribeToNotifications again.
And the other question that i have is : given that here we don't have an useEffect that listen to the needsSignature state, i guess that the plan is to have that useEffect in the manager?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

given that here we don't have an useEffect that listen to the needsSignature state, i guess that the plan is to have that useEffect in the manager?

Yes, exactly, that was something I wanted to leave to the state machine manager, given that we could have different machines based on the area (preferences or modal).

Trying to figure out how are you thinking to handle the action after the signature?

Similar to above, I was hoping the manager would handle this. These functions just attempt to "optimistically" call the API, and if it fails, it'll let us know either with the error or a state change.

}

const getEmail = async () => {
const { needsSignature, email } = await getJurorEmail(account)
Copy link
Contributor

Choose a reason for hiding this comment

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

Giving a second thought to this, i think that here we are going to be fetching the juror email every time an account is connected, and when the cookie has expired we are going to ask the juror to sign a message just for connecting his account and not sure if that is what we want.
The way i see this is that we need to do that only when we are subscribing to notifications through the modal or entering the global preferences not every time the juror connect his account to interact with the dashboard.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Yes, it sounds like we should do this in a callback instead.

const fetchSubscriptionDetails = async () => {
const response = await getSubscriptionDetails(account)

if (!asyncCancelled.current) {
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 used the same asyncCancelled ref here and after, but thinking about it, useEffects() should contain their own local cancellation.

@@ -0,0 +1,142 @@
import React, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nitpick: we may want to rename this file to be EmailNotificationsApiProvider for clarity.

const response = await subscribeToNotifications(account, email)

if (response.error && !response.needsSignature) {
return response.error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this, we may want to throw the error instead (and perhaps all the requests should be throwing those errors, similar to https://github.com/aragon/aragon/blob/master/src/components/GlobalPreferences/Notifications/notification-service-api.js#L60).

Base automatically changed from email-notifications-testing to development May 25, 2020 20:44
@sohkai sohkai marked this pull request as draft July 2, 2020 20:48
@sohkai sohkai changed the base branch from development to master July 3, 2020 09:56
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.

None yet

2 participants