WildAid / o-fish-ios

iOS app for the Officer's Fishery Information Sharing Hub (O-FISH). The mobile app allows fisheries officers to document and share critical information gathered during a routine vessel inspection.
Apache License 2.0
33 stars 15 forks source link

Cannot add user avatar photo. #360

Closed coltonlemmon closed 4 years ago

coltonlemmon commented 4 years ago

Describe the bug When attempting to edit the avatar photo an alert appears to select "Camera" or "Photo Library" but selecting either button does nothing.

To Reproduce Steps to reproduce the behavior:

  1. Go to user information view from map (In the navigation bar).
  2. Select edit under avatar image.
  3. Select either "Camera" or "Photo Library"
  4. Nothing happens.

Expected behavior An alert requesting user permission to access the camera or photo library the first time. Then either the camera or photo library depending on what the user selects.

Screenshots N/A

Smartphone (please complete the following information):

bladebunny commented 4 years ago

If this is on ProfilePageView, it looks like a logic bug. Code checks to see if there's an existing profilePicture before trying to capture an image and set it on, profilePicture, and if that object doesn't exist it bails. So, if there is no picture there is effectively no way to set it.

In terms of logical flow of the app, MainNavigationRootView creates PatrolBoatView which then creates ProfilePageView, passing in the image model if it exists. PatrolBoatView uses a service object called PhotoQueryManager to get the initial image model that is failing down the chain. Finally, PhotoQueryManager is trying to fetch it from Realm.

So, even though there's a placeholder image on the actual view, accessing the camera or photo library is failing because the user has a nil photoimage because one was not fetched from Realm.

I have a fix for the first part, getting and setting an image, but the PhotoCaptureController is not saving the selected image to Realm for some reason. Looking at that now...

bladebunny commented 4 years ago

I've traced it all the way through and it is calling a method to save to Realm realm.add(photo) in PhotoViewModel. Not exactly sure why that is failing for me. Could it be a sandbox issue?

Sheeri commented 4 years ago

Thanks @bladebunny! This is good detective work. It might be a sandbox issue; I will try adding a photo and checking the Realm logs to see if anything sticks out for me.

I wonder if it would work if you add a photo through the web interface first, and then tried to change it in the app? I wonder if it's trying to change an existing photo, and the existing photo doesn't exist? (Could you try that out?)

Sheeri commented 4 years ago

(oh! And even if you don't want to try this out - if you want to get hacktoberfest credit for researching this, feel free to submit a PR that we will just close, but NOT mark invalid - I want to acknowledge that doing that research is valuable work, but don't know how else to do it. 'Meaningful work' is so much more than a PR!)

bladebunny commented 4 years ago

Adding PR tha resolves issue with user not being prompted to add from Camera/Photos. If we can solve the realm save issue it should be good.

am-MongoDB commented 4 years ago

See https://github.com/WildAid/o-fish-ios/pull/366 for why this isn't an issue for the mobile app