Skip to content

Conversation

@karthik-ir
Copy link
Collaborator

No description provided.

}
}

export function forceFetchProfile(pubkey,getState){
Copy link
Owner

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) {

export function forceFetchProfile(pubkey,getState){
return async function (dispatch) {
const contactList: ContactList = getState().contactList
var cont = contactList.findContact(pubkey)
Copy link
Owner

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))
Copy link
Owner

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) {
Copy link
Owner

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 :(

Copy link
Collaborator Author

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.

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.

2 participants