Plant-for-the-Planet-org / treemapper

TreeMapper extends the Plant-for-the-Planet Platform and allows on site data registration for restoration initiatives.
https://treemapper.app
Other
26 stars 2 forks source link

Species sync crash if using same account on two devices #356

Open norbertschuler opened 3 years ago

norbertschuler commented 3 years ago

Describe the bug If a user is using the Treemapper app on two devices with the same account and having saved a species on one device and tries to store it on the other device with a species sync at logout as well, the app got stuck with an error as the API call POST https://app-development.plant-for-the-planet.org/treemapper/species to store the species fails with errror 400 as following:

Request POST https://app-development.plant-for-the-planet.org/treemapper/species

{
  "scientificSpecies": "sspec_G9J2HCzvnLkm97owCz",
  "aliases": "Arbutus xalapensis",
  "description": "Test\n",
  "imageFile": "data:image/jpeg;base64,...
}

Response:

{
  "code": 400,
  "message": "Validation Failed",
  "errors": {
    "errors": [
      "you already have defined a species based on the provided scientificSpecies id"
    ],
    "children": {
      "aliases": {},
      "imageFile": {},
      "description": {},
      "scientificSpecies": {}
    }
  }
}

Crash: TypeError: undefined is not an object (evaluating 'addFromAlreadySyncedSpecies(specie.guid, alreadySyncedSpecies).then')

Is it on a Production or Development Build? develop (maybe also production)

To Reproduce Steps to reproduce the behavior:

  1. Login on two devices and add a new species
  2. Store species on one device
  3. Store species on second device (e.g. by sync on logout)
  4. See error

Expected behavior Avoid error if API fails with above error.

What actually happens App got stuck on sync species screen.

Screenshots Screenshot_1622293646Screenshot_1622294149

Smartphone (please complete the following information):

norbertschuler commented 3 years ago