Commit Graph

97 Commits

Author SHA1 Message Date
Ken-ichi
f45108036f Sound recording (#1164)
* Added basic navigation test for StandardCamera & SoundRecorder
* Abstracted camera nav buttons and used in SoundRecorder
* Show sounds in the MediaViewer
* Added sounds to ObsEdit, w/ MediaViewer support
* Ensure sounds get both uploaded and added to observations
* Local sound deletion
* Remote sound deletion
* Rudimentary and deeply unperformative sound visualization

Closes #869
2024-02-22 22:02:25 -08:00
Johannes Klein
74479d7d7f Navigate to Media viewer from suggestions (#1162)
* Add method to get innerPhotos array

* Rename component

* Get list pf photos in suggestions

* Add Media viewer modal

* Rename prop

* Update MediaViewer.test.js

* Update test IDs
2024-02-22 15:20:19 +01:00
Ken-ichi Ueda
dca5b4235f Numerous eslint fixes 2024-02-21 10:49:08 -08:00
Amanda Bullington
045ce6f789 Improve Jest performance (#1160)
* Use faker import with specific locale

* Add global beforeAll to initiate i18next
2024-02-16 16:17:00 -08:00
Amanda Bullington
d147ac5d54 Explore defaults to viewer's location (#1157)
* Show observations by defaulting to user location

* Remove log

* Create useHeaderCount hook to load user location count before global count

* Header count and location permission fixes

* Remove log

* Fix Explore tests

* Test fixes and add blocked/denied state
2024-02-15 18:28:33 -08:00
Ken-ichi
012814d9a3 Fix MyObs test flakiness by waiting for app to settle before closing realm (#1156)
* Fix MyObs test flakiness by waiting for app to settle before closing realm
* Moved currentUser down into the Announcements component
2024-02-15 14:47:33 -08:00
Ken-ichi Ueda
54f3f9eb47 Extracted unique Realm test setup code into a helper
There's still some required copy-pasting because jest is weird, but at least
there's less of it.
2024-02-14 15:40:35 -08:00
Ken-ichi
ef1db46bae Bugfix: withdrawing ID was deleting the ID body (#1150)
Additionally,

* Adds tests for ID withdraw and restore
* Renames withdrawOrRestoreIdentification function for clarity
* Adds some accessibility labels for testing and accessibility

Closes #1129
2024-02-14 11:22:13 -08:00
Amanda Bullington
8e6269c8d0 Wrap realm.write in safeRealmWrite transaction (#1123)
* Add a safeRealmWrite transaction for better logging around writes; code cleanup and realm update

* Add safeRealmWrite to tests and make sure action is called synchronously

* Fix final test

* Only write to realm when useObservationsUpdates data changes; code cleanup

* Code cleanup
2024-02-09 16:16:32 -08:00
Johannes Klein
49e9339c51 ObsDetail media masonry layout (#1085)
* Simple masonry layout

* Scrollable masonry

* Render SoundSlide in Masonry

* Fix previos commit

* Fix param name

* Optional style for photo slide

* Rename

* Use photo slide

* Open media viewer on press

* Rename components

* Rename component

* Add test for tablet obs media
2024-01-26 11:57:42 +01:00
Johannes Klein
47b3525228 Announcements (#1081)
* Update iNatjs

* Add webshell dependency

* Basic announcement fetching component

* Styling

* Dismiss function

* Error handling TODO

* Add param

* React to link presses

* Missing code

* Add unit test

* Add string

* Refactor search query and dismiss to use react-query

* Activity indicator when refetching

* Add query provider to test

* Mock component in other integration tests

* Move user agent to api

* Throw error instead of logging
2024-01-24 22:22:50 +01:00
Ken-ichi
e6b5cb8aa6 Obs details sounds (#1062)
* Extracted non-photo stuff from PhotoDisplay
* Separate component for FaveButton
* Prevent faves while signed out
* Separate component for nav header
* Stick nav header while scrolling until tabs
* Nav header has slight gradient for visibility over white content
* Renamed ObsDetails media components so they're not focused on photos
* Data and layout changes leading up to sound player on ObsDetail
* Add sound player to ObsDetails
* Swiping away while playing should pause playback
* Swiping back to sound and playing again should resume where you left off
* Allow viewing media while offline (images may be cached)
* Stop playback when navigating away from ObsDetails
* Fetch sounds in Explore so we can show sound icon
* Map all observation objects in explore with Realm-ish attributes
2024-01-22 13:12:01 -08:00
Ken-ichi
4e42ebc262 Community taxon opt out notice (#1060)
* Shows notice when user or obs is opted out of Community Taxon on ObsDetails
  (closes #882)
* Unifies mapApiToRealm methods around a single interface
* Ensure that the remote obs used on ObsDetail is normalized to look like a
  local obs
* Ensure some tests that use signIn() have isolated Realm instances
* Update current user's obs from ObsDetails (closes #1045) 
* Fixed CC0 license display on ObsDetails (was not actually related to
  updating the local copy of the obs
2024-01-18 20:16:30 -08:00
Ken-ichi Ueda
6b37ca1d2b Several minor fixes
* use showSwitchMapTypeButton option in Location Picker and ObsDetails map
* title of comment bottom sheet to "Add Comment"
* fixed position of current location button on map
* text of geoprivacy on ObsDetails to "Geoprivacy: Open"
* don't load offline suggestions while loading online
2024-01-16 17:52:23 -08:00
Ken-ichi
b815f451ea Offline fixes (#1025)
* Changed the default React Query retry handler to be synchronous; being async
  meant it returned a promise, which React Query interpreted as true-ish,
  which meant it retried forever
* React Query retry handler should log info about its query key, which should
  make those problems a bit easier to debug given a log
* Prevent useObservationUpdates from throwing errors when network requests
  fail, which they always do while offline
* Added our own ErrorBoundary that shows a component trace
* Prevent several uses of useAuthenticatedRequest when not online
* Work around bug in vision-camera-plugin-inatvision where it can't get
  dimensions of photos in Android
* Actually throw errors when vision-camera-plugin-inatvision's predictImage
  throws unexpected errors
* Allow online suggestions while signed out using anonymous JWT
2024-01-11 17:18:04 -08:00
Ken-ichi
b18fd0408b Crash when uploading after deleting unsynced observation (#1010)
Syncing was broken when an unsynced obs was deleted

The main problem here was that MyObs state has a list of observations that
need upload, but since it was a plain array of Realm objects it crashed when
one of those objects was invalid, which happened after deletion. This fix
isn't great: it just makes it so the thing in state is a Realm.Results
object, which will update dynamically when its underlying data changes. We
could also JSONify what we have in state, but then you get into problems of
nested objects and deep JSONification.

Also
* Delete local obs if remote doesn't exist
* Bugfix: ObsDetail tried to mark non-existent remote obs as viewed
* Tried to handle react query retries better
2024-01-09 14:47:07 -08:00
Ken-ichi
799e0f4c4f Restore tests removed in recent suggeston fixes (#1001)
* Restored Suggestions navigation tests
* Restored SuggestionsWithSyncedObs.test.js tests
* Mocked vision-camera-plugin-inatvision instead of useOfflineSuggestions
* Removed unnecessarily complex object from navigation params

There were a lot of issues here, but the main ones (I think) were related to
rendering all the navigators and waiting for asynchronous stuff to happen
before proceeding with the test.
2024-01-05 19:48:46 -08:00
Ken-ichi Ueda
7840ba2751 Bugfix: could not add an ID using Suggestions from Explore 2023-12-15 20:50:37 -08:00
Ken-ichi
f7dc08a704 Suggestions fixes (#972)
* Bugfix: TaxonDetails was crashing if it received a null taxon
* Send lat and lng instead of latitude and longitude to the score_image
  endpoint
* Show offline suggestions when you are offline
* Show notice when viewing offline suggestions
* Moved code unique to useOnlineSuggestions into that file
* Ensure we use a medium size image to get suggestions when dealing with
  remote URLs
* More logging around React Query retries
* Use default retry logic for useAuthenticatedQuery
* Made a module-resolver shortcut for tests
* Move offline notice above top suggestion; hide when offlines exist but onlines do too
2023-12-15 19:58:12 -08:00
Ken-ichi
8119a3e5ca Taxon detail media viewer (#966)
* Access MediaViewer from TaxonDetails
* Added our own presets for ActivityIndicator
* TaxonDetail should show a local taxon if one is available
* Made it a little easier to import the custom logger
* Refactored MediaViewer to accept photo-like objects instead of URIs
* Added license / attribution button to MediaViewer
* Moved delete button into MainPhotoDisplay so each photo has its own button
  and it can be laid out relative to its photo
* Add custom header to MediaViewer when accessed from TaxonDetial
* Allow DisplayTaxonName to accept custom text components as props
* Added darker bg to photo on TaxonDetail to make title more legible
2023-12-14 17:18:41 -08:00
Amanda Bullington
73d2e9944b Suggestions first looks for online, then offline predictions; fixed tests to reflect this (#968) 2023-12-14 12:42:10 -08:00
Amanda Bullington
35f87cce43 Update title for unsynced observations, ObsEdit (#965)
* Show edit title; add tests; set current obs before nav to ObsEdit screen

* Use edit title when obs is not synced; rewrite ObsEdit tests to show nav works correctly with useStore

* Remove uuid in params to ObsEdit; no longer needed

* Fix e2e by ensuring ObsEdit doesn't rerender with deleted obs
2023-12-14 11:46:46 -08:00
Ken-ichi Ueda
0ec3f02d42 Test fix
It's not clear to me why this fixes the TaxonSearch test, which seems to fail
even when you mock those API responses with empty data.
2023-12-13 11:16:34 -08:00
Amanda Bullington
f32a8812f5 Offline suggestions (#961)
* Use offline model for displaying sugggestions

* Simplify Suggestions/TaxonSearch screens using hooks

* Use updateObsKeys function from useStore

* Simplify code and fix unit tests

* Fix tests for offline predictions

* Fix faker urls

* Fetch remote taxa to display taxon photos in Suggestions

* Fix useTaxon code and test

* Use online vision results as backup for offline results

* Fix tests and add test for online predictions

* Use Flatlist for Suggestions and fix tests

* Move API call out of Attribution and fix test

* Fix tests

* Fix test warnings
2023-12-13 10:11:21 -08:00
Ken-ichi
d3f1f8ed6e View photos in MediaViewer from ObsDetail (#962)
* Unit tests for MediaViewer
* Added editable prop to MediaViewer
* MediaViewer navigation test
* Made MediaViewer a modal
2023-12-13 09:33:06 -08:00
Amanda Bullington
bded964b0a Add vision property to AR camera & suggestions for observation/id creation (#952)
* Add vision param to identification create; test vision false on TaxonSearch and true elsewhere

* Test that vision attribute is only used from Suggestions screen

* Add owners_identification_from_vision attribute to observations

* Fixes for vision attribute

* Make sure taxon is applied from Suggestions/TaxonSearch via ObsEdit

* Fix for ids vision

* Fix Suggestions tests
2023-12-07 11:07:47 -08:00
Amanda Bullington
808cbee452 Replace ObsEditProvider with zustand for global state management (#948)
* Add zustand to app

* Begin replacing ObsEditProvider with zustand for global state

* Use store and add tests

* Fix bugs

* Add test to check for deleted photos in StandardCamera

* Make sure evidence is only added to current observation; submit comment with ID on ObsDetail

* Fix ObsEditWithoutProvider tests

* Move store to where it's needed

* Fix tests

* Await evidence being added to obsPhotos from camera

* Add a note about slices to useStore
2023-12-05 14:10:00 -08:00
Ken-ichi
0c7c807b56 Realm & other bugfixes (#950)
* Updated faker; fixed bug w/ DisplayTaxonName trying to modify a Realm object
* Fixed crash going from ObsDetail to ObsEdit
* Fixed bug fetching observation dates (not clear how this didn't instantly crash_
* Bugfix: MyObs observation fetch was failing on taxa w/ float rank_level
2023-12-04 13:47:00 -08:00
Ken-ichi
13f3b21bc0 Bugfix: handle blank LocalPreferences.last_sync_time on first sync (closes #935) (#936) 2023-11-30 11:42:09 -08:00
Ken-ichi
105096412b Fix broken offline coord fetch by only reverse geocoding in one place (#932)
Fixes #907. Also adds an ObsEditOffline test for adding a new obs offline...
which doesn't actually catch this bug, but may catch others. This bug may
have been due to a race condition that doesn't happen in the test env for
some reason.
2023-11-29 10:57:53 -08:00
Angie Ta
ad60db9e62 Merge branch 'main' into 852-observations-show-upload-button-and-incorrect-no-photos-icon-on-explore 2023-11-27 19:46:00 -08:00
Amanda Bullington
a401854475 Sync deleted observations from server (#924)
* Realm updates for cascading deletions

* Delete local observations from remote list

* Add tests for deleting local obs which were deelted on server

* Fix: don't create embedded objects explicitly
2023-11-27 15:07:23 -08:00
Amanda Bullington
1a27ef68cb Upgrade to Realm 12 (#925)
* Update to realm 12

* Remove unused mocks to fix some tests

* Fix test by unmocking ObsEditProvider

* Fix more tests by removing mocks/changing when tests write to realm

* Remove mocks on ObsEdit component test and fix accessibility labels

* Fix hooks tests with realm

* Set test path for realm; finish fixing tests

* Small tweak

* Upgrade realm/react library

* Migrate schema
2023-11-22 13:01:59 -08:00
Angie Ta
d18b30256c Add back ObsStatus to ObsGridItem and tests 2023-11-21 17:23:40 -08:00
Ken-ichi Ueda
38e75d3cdf Remove some unecessary react-navigation mocks 2023-11-20 11:09:36 -08:00
Angie
ab00dd8f43 Merge pull request #920 from inaturalist/852-observations-show-upload-button-and-incorrect-no-photos-icon-on-explore
852 observations show upload button and incorrect no photos icon on explore
2023-11-17 16:07:22 -08:00
Amanda Bullington
361ad1d1f5 Performance: simplify ObsEditProvider (#908)
* Simplify ObsEditProvider by moving functions into local state & calling reducer less frequently

* Fix delete all observations

* Fixes

* Move index selection to MediaViewer via params

* Access ObsEditContext on top level of ObsEdit and pass props

* Move context to top level screen components

* Fix tests

* Use waitFor to fix ObsDetails integration test

* Alphabetize props; remove realm check; refactor new Id method

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2023-11-17 12:35:29 -08:00
Angie Ta
e55c199d1b Merge branch 'main' into 852-observations-show-upload-button-and-incorrect-no-photos-icon-on-explore 2023-11-15 18:32:52 -08:00
Ken-ichi Ueda
f6592c768d Added Explore test to look for correct status 2023-11-15 17:45:00 -08:00
Amanda Bullington
7de3790230 Performance: move upload reducer out of ObsEditProvider into MyObservationsContainer (#879)
* Move upload functionality into MyObservations, out of ObsEditProvider

* Move upload into helper function

* Fixes for ObsEdit -> MyObs flow

* Progress on making uploads faster

* Update performance test

* Fix toolbar progress

* Fix tests for observation upload flow

* Fixes from code review; fix e2e test for signed in user by bypassing permission gate

* Hide sign up test when keyboard visible; fixes Android e2e test

* Comment out permissions code in e2e test to see if it's only needed locally

* Comment out permissions gate for signed out user iOS

* Use focused hook to stop ObsEdit from rerendering while user is on other screens

* Restore reassure in branch

* e2e code cleanup
2023-11-15 11:40:11 -08:00
budowski
3c6f453bf3 Native image picker (#828)
Uses a fork of
https://github.com/react-native-image-picker/react-native-image-picker that
forces an old-style Android native photo picker to ensure we get all the
photo metadata we need. Closes #431 and closes #569

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2023-11-06 19:41:09 -05:00
Amanda Bullington
5913fb511e Energy usage / performance improvements (#844)
* Remove console statements in production build

* Move uploadReducer into separate file

* Create reducer for creating obs; combine reducers

* Fixes with createObsReducer

* Move album, passes test states out of global context

* Bug fixes for ObsEdit flow

* Create photo gallery container

* Set accessibility test todo for PhotoGallery

* Improve FlashList performance MyObs

* Prevent flicker on modal close

* Create less rerenders in MyObservations

* Memoize drawer items for less rerendering

* Memoize custom tab bar

* Remove unused libraries and update snapshot

* Fix and prune dependencies

* Add AddObsModal tests

* Fix e2e test android by making comment confirm button visible
2023-11-02 11:03:48 -07:00
Ken-ichi
e3eb739388 Suggestions nav fix (#833)
* Bugfix: navigation was broken when choosing a taxon on Suggestions
* Test for Suggestions navigation

The thorny part here was isolating the test Realm db. We should really have a
generalized strategy for this, but this works for this task.
2023-10-25 08:34:39 -07:00
Amanda Bullington
d38720f9b2 Tests & fix for upload progress (#826)
* Add unit tests for Toolbar upload progress

* Tests and improvements to upload progress bars

* Fix tests

* Update type for showsExploreIcon

* Fix tests

* Clear realm before MyObs tests
2023-10-20 16:01:48 -07:00
Ken-ichi
dacd8788ec Permission gate layouts (#743)
Primarily adds designed layouts for permission gates (also referred to as permissions priming).

* moved permission gate business logic into a container
* use react-native-permissions exclusively
* Show PermissionGate as a modal
* Basic unit tests for PermissionGate
* Consistent content width on tablet, other minor style changes
* Allow PermissionGate to be used outside of nav hierarchy
* Use user location on Explore after getting permission
* Remove redundant 'always' location perm in ios
* Isolate current location button in the Map component, which uses location fetching functionality from react-native-maps instead of our own
* Updated cocoapods; matched INatIcon.ttf to sha1 hashes
2023-10-18 16:47:12 -07:00
Amanda Bullington
7d20f6aa81 Suggestions (using server data) (#821)
* UI overhaul for Suggestions

* Updates to suggestions

* Update permissions library and Podfile

* Get tests passing

* Add tests for suggestions

* Update snapshot

* Add comment prompt & box to TaxonSearch

* Add empty state

* Nav and loading fixes

* Add more tests to Suggestions flow

* Fix tests

* Fix tests
2023-10-13 14:46:05 -07:00
Amanda Bullington
47c5d8e2fd Drag and drop photos (#813)
* Use drag and drop to let a user change photo positions

* Fix tests

* Add test for EvidenceList

* Fix tests

* Fix state for no evidence / no observation photos

* Add unit tests for empty list and displaying obs photos
2023-10-11 13:55:27 -07:00
Ken-ichi Ueda
6d03980a2c Restore canGoBack in BackButton 2023-09-19 16:58:48 -07:00
Amanda Bullington
5bfa7940e1 Refactor ObsDetails and show ID after agree button pressed (#738) 2023-08-16 16:09:46 -07:00
Amanda Bullington
9c6106f5d0 Refactor tests to use minimum viable test factories (#681)
* Make minimum viable RemoteComment

* Minimum vialbe RemoteIdentification

* Minimum viable remote project, place, and messages

* Create minimum viable records for all remote factories

* Remove factories for local device data

* Minimum viable local taxon, comment, id

* Minimum viable for local observation photo (photo has no primary key)

* Minimum viable LocalUser

* Minimum viable record for LocalObservation
2023-06-27 17:06:01 -07:00