-
Notifications
You must be signed in to change notification settings - Fork 48
Recieve chat messages from unknown contacts #32
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
base: master
Are you sure you want to change the base?
Conversation
app/actions/contact.js
Outdated
| } | ||
| } | ||
|
|
||
| export function forceFetchProfile(pubkey,getState){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to pass the getState function like this, redux-thunk provide it for you already. In the line below, just add the getState argument like this:
return async function (dispatch, getState) {
app/actions/contact.js
Outdated
| export function forceFetchProfile(pubkey,getState){ | ||
| return async function (dispatch) { | ||
| const contactList: ContactList = getState().contactList | ||
| var cont = contactList.findContact(pubkey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the flow typing as much as you can, and let/const :
const contact : ?Contact = contactList.findContact(pubkey)| console.log(data) | ||
|
|
||
| const contact: Contact = Contact.fromProfileData(pubkey, data) | ||
| await dispatch(contactListAction.priv.storeContactInDirectory(contact)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not really obvious, but storeContactInDirectory will already store the contact properly in the directory AND the pool, so no need to call storeContactInPool just after
| dispatch(priv.chatReceived(contact, id, message)) | ||
| dispatch(sendChatAck(contact, id)) | ||
|
|
||
| var contact = dispatch(forceFetchProfile(from,getState)).then(function (cont) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use async await instead of chaining the promise with .then(). otherwise my brain melt :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get Actions must be plain objects. Use custom middleware for async actions. If i use that way. No idea why.
No description provided.