vinnymac / PokeNurse

💉 A tool for Pokémon Go to aid in transferring and evolving Pokémon
284 stars 55 forks source link

Fix batch transfer #206

Closed hacknug closed 7 years ago

hacknug commented 7 years ago

This works but transfers the selected mons one by one without any delays. We should change it so it uses the native batch-transfer method Pokémon GO uses when users select multiple mons from the selection screen like explained here: https://github.com/cyraxx/pogobuf/wiki/pogobuf.Client-Pok%C3%A9mon-Go-API-Methods#releasepokemonpokemonids--promise

vinnymac commented 7 years ago

So I guess we should just map the selectedPokemon to an array of ids and then pass that in. According to those docs you posted it is just expecting an integer array.

So instead of using a for loop, just pass in

const selectedPokemonIds = selectedPokemon.map(p => p.id)
// ----
await getClient().releasePokemon(selectedPokemonIds)

I wonder why the old way of batching with pogobuf stopped working.

hacknug commented 7 years ago

I tried building the array in my loop and then pass it to the method outside the loop so it would transfer them all at once but it didn't work for some reason (log said selected id's got transfered but every mon would still be there).

vinnymac commented 7 years ago

@hacknug did you call dispatch(transferPokemonSuccess(selectedPokemon[i])) for each individual id? Or just one? That success event is what makes them disappear from the list if I recall correctly. So I would iterate over all the ids once the server responds.

Or maybe I am misunderstanding, were they transferred upon refresh/restart?

hacknug commented 7 years ago

What I did was something like this:

function transferMultiplePokemon(selectedPokemon) {
  return async (dispatch) => {
    var idArray = []
    for (var i = 0; i < selectedPokemon.length; i++) {
      idArray.push(selectedPokemon[i].id)
    }
    try {
      await getClient().releasePokemon(idArray)
      dispatch(transferPokemonSuccess(idArray))
    } catch (error) {
      dispatch(transferPokemonFailed(error))
      handlePogobufError(error)
    }
    await dispatch(refreshPokemon())
  }
}

The console would say and array of id's was trasnfered but after calling refreshPokemon() nothing would happen and everything would still be there.

vinnymac commented 7 years ago

I attempted to try and make travis happy myself just now too. Hopefully it will be useful again soon.

hacknug commented 7 years ago

We could make him build packages for the different platforms so people who don't know how to use git can test new features or fixes

vinnymac commented 7 years ago

With the latest travis patch I made it looks like he is building again. It'd be cool if we got him building more than linux, but that is the easiest way to do it right now. For windows I would likely use something like appveyor. Uploading the builds is an interesting idea, not sure where we would store them free of charge though.

YesThatAllen commented 7 years ago

Uploading the builds is an interesting idea, not sure where we would store them free of charge though.

isn't that what github allows when you are about to publish a release?

hacknug commented 7 years ago

@YesThatAllen I don't think it works with PRs

vinnymac commented 7 years ago

Yea we would need a place to put the files. Like another repo, preferably we would use a cdn.

vinnymac commented 7 years ago

I think we might want to consider doing the same thing for evolve if we want to get this out, shouldn't be that much more work. You can then delete the code for the batch method.

hacknug commented 7 years ago

Trying to transfer a mon you don't have enough candy for logs EVOLVE_POKEMON_SUCCESS even though it has no effect. We should/could also add support for item evolutions: https://github.com/cyraxx/pogobuf/wiki/pogobuf.Client-Pok%C3%A9mon-Go-API-Methods#evolvepokemonpokemonid-evolutionrequirementitemid--promise

YesThatAllen commented 7 years ago

The transfer works, and the complete notice comes up right away (nice!)

Clicking OK after transfers prompts a refresh of the list, having that refresh after the evolution would be a good add.

vinnymac commented 7 years ago

I am going to merge this since we can start work on the rest of it together. I think the item evolutions can be a future release. I want to get this stuff shipped asap.