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

Recieve chat messages from unknown contacts #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

karthik-ir
Copy link
Collaborator

No description provided.

@@ -44,6 +45,34 @@ export function fetchProfile(pubkey: string) {
}
}

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.

None yet

2 participants