Commit Graph

30 Commits

Author SHA1 Message Date
Corey Farwell
a43446909c Remove the need to specify TypeScript file extensions in imports (#3094)
* Don't require TS extensions in imports

* Resolve all import extension errors

* Remove file extension from import paths used in mocks

* Remove .d of type definition file paths

* Remove .d of type definition file and import as type

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2025-09-07 23:41:42 +02:00
Johannes Klein
49091f8fc4 Enable React Compiler (#3082)
* Update package.json

* Update package-lock.json

* Enable plugin

* Update package.json

* Update package-lock.json

* Update .eslintrc.js

* Create a new object instead of mutating the existing one

* Update SoundRecorder.js

* Do not mutate prop directly

* Do not mutate store value directly

* Disable compiler for zoom hook

Because it uses reanimated logic, and previous work laid out we should specifically disregard a rule of react here, unsure what to do here for now.

* Move array for tracking results into component

* Disable compiler for StandardCamera

* Do not mutate store value directly

* Disable compiler for FullPageWebView

* Do not mutate route param

* Remove unnecessary check if state is true before setting it to false

* Fix: user might be undefined

* Update reanimated usage with new compiler compliant API

* Fix: taxon might be undefined

* Fix: taxon might be undefined

* Fix: common pitfall of trying to render text outside of Text component

* Update interface

* Add package override

* Update package-lock.json

* Refactor updating of user preferences into User model

* Remove no memo directive from zoom

* Update file imports

* Migrate safeRealmWrite to TS

* Update interface and import path

* Update interface

* Refactor useLocaalObservation hook to not mutate return value of a function that should not be mutated

* Update tests to new return structure

* Remove useSafeRoute hook

We get the same information from error contexts and surrounding documents, and this hook was violating the rules of react by conditionally calling another hook.

* Use optional chaining

* Update TaxonNamesSetting.test.js

* Fix: use optional chaining

* Extend on RNTLs renderHook instead of re-implementing

* Remove unnecessary mock

* Remove unnecessary mock

* Remove unecessary mock

* Remove trailing spaces
2025-09-01 17:06:51 +02:00
budowski
836438cd1e MOB-752 - use FasterImageView for caching obs/taxon/project images (#2887) 2025-06-26 11:10:01 -07:00
Amanda Bullington
d1421efd5b Show date ranges instead of project type on collection/umbrella projects (#2312) 2024-10-28 13:59:59 -07:00
Amanda Bullington
653340d854 Add infinite scroll to Projects (#2185)
* Implement infinite scroll in Projects

* Styling fixes for empty state in projects; add infinite loading wheel

* Resolve require cycle from ObsFlashList and FlashList shared components

* Order by distance and remove radius for nearby projects fetch

* Code cleanup

* Fix test

* Code cleanup

* Minor tweaks to search API request and results
2024-09-25 11:17:32 -07:00
Amanda Bullington
abd4bcee23 Refactored location fetching for accurate locations (#1788)
* Refactor to use watchPosition

* Update useWatchPosition with permissions/retry

* Replace useUserLocation with useWatchPosition and fix tests; return userLocation from watch position hook

* Only update observation keys when there's an observation

* Improve TypeScript definitions

* Revert TypeScript commit

* Revert "Only update observation keys when there's an observation"

This reverts commit a4cd17a513.

* Code cleanup: make useWatchPosition more modular

* Code cleanup; location permission in ObsEdit instead of subcomponent

* Use correct accuracy in Camera photos

* Camera fixes

* Fixes to watching position in ObsEdit

* Fix useWatchPosition tests

* Fix tests

* Make sure state updates when renavigating to OsEdit; test fixes
2024-07-16 09:23:09 -07:00
Ken-ichi
f3bcec2d2e Continuous location fetch in the cameras (#1673)
* Fetch location continuously in cameras until accuracy falls below threshold
* Unit test for useUserLocation
* Added untilAcc option to useUserLocation
* Bugfix: ObsEdit was not always fetching location for new camera photos

Closes #1340
2024-06-12 11:18:12 -07: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
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
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
Amanda Bullington
92fc62b5f8 Projects / ProjectDetails UI (#788)
* Start on project / details UI overhaul

* UI tweak

* Show HTML in ProjDetails; close search bar

* Add OverviewStats and relevant fetches to ProjectDetail

* Allow user to leave/join traditional projects

* Fix tests with mock react-native-paper
2023-09-20 13:09:31 -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
Amanda Bullington
7a98b6faf1 Timeless dates (#457)
* Add DateDisplay to ObsCard and make first pass at translation strings

* Add failing tests (due to lack of localization) for timeless dates

* WIP: trying to ensure i18next gets initialized before tests run

The remaining test failures might be legit. This probably breaks the actual
app, though.

* Got the rest of the tests working

* Updated tests to assume UTC
* Updated README to advise against using `npx jest` so test runs always have
  the env vars we specify in our `npm test` script
* Moved i18next initialization to an explicitly-named file
* Use i18next init function in app
* Fixed up remaining tests

* Added test for non-English localization of date format

* Cleanup

* Made DateDisplay explicitly handle strings not Dates

* Restore skipped localization tests for MyObservations

* Remove duplicative tests from DateDisplay unit test

* Added note to the README about initializing i18next

* Updated change to DateDisplay in main

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2023-02-14 22:14:38 +01:00
Chris
4f732bace9 Create taxon name component (#444)
* Create taxon name component
* Switch to classnames

Closes #435
2023-02-07 23:13:27 -05:00
Chris
44b28ff54e Incremental changes to navbar component (#407)
* Incremental changes to navbar component

* Fix tests

* Fix ally tests

* Space parens

* Add box shadow for android

* Add accessibility role

* Add a11y

* lint

* Add basic tests

* Fix tests

* Fix tests

* Update colors

* Merge remote changes

* Lint

* Add more comprehensive test

* Incremental changes to navbar component

* Fix tests

* Fix ally tests

* Space parens

* Add box shadow for android

* Add accessibility role

* Add a11y

* lint

* Add basic tests

* Fix tests

* Fix tests

* Update colors

* Merge remote changes

* Lint

* Add more comprehensive test

* switch to react native paper

* Make explore button nav to explore

* Remove inline styles

* Fix border on android

* Use user icon component in nav bar

* Rename props

* Remove t from nav button

* Change accessibility props

* Use a11y role for tabs

* Update NavBar.js

* Mock route for messages

* Mock route in tests

* Remove not needed function

* Remove NavBar unit test

* Create integration test file

* Add container mock to user profile test

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2023-02-03 11:42:55 +01:00
Johannes Klein
1b4039eb36 417 eslint testing (#419)
* Add eslint-plugin-testing-library dependency

* Enable plugin inside tests folder

* Fix errors given by eslint-plugin
2023-02-01 12:50:59 +01:00
Johannes Klein
14d0239468 308 accessibility tests (#393)
* Regroup accessibility label strings at end of strings file
* Add accessibility test to AddID
* Add a11y labels to AddID
* Add a11y test to StandardCamera
* Add a11y props to StandardCamera
* Remove unit test with only todos
* Add a11y test to Messages
* Refactor PhotoScroll test into own file
* Add a11y test to ObsDetails
* Add a11y test to ObsList
* Add a11y matcher to PhotoGallery test
* Add a11y matcher to ProjectDetails test
* Add a11y matcher to ProjectObservations test
* Add a11y matcher to Projects test
* Add a11y props to ProjectList
* Add a11y props to ProjectTabs
* Add a11y matcher to Search
* Add a11y matcher to UserProfile test
* Add a11y test matcher to UserText test
* Update react-native-accessibility-engine
* Add a11y matcher to Tabs test
* Add a11y label to a selectable photo
* Refactor DataTab tests into separate file
* Refactor ActivityTab test out into own file
* Added a test how to check if a component uses a mocked container
* Add wrong a11y props to TextInput left icon
* Enable a11y test with actual BottomSheet because mock does not pass a11y props down
* Add a11y default props to Button
2023-01-27 12:30:57 -08:00
Ken-ichi
aa0eabcc59 Fix crash on Android after login (#347)
The problem has something to do with the unicode capitalization code that got
ported from the web. It seems like the JS engine in Android has a problem
with calling toUpperCase() on some unicode characters, and this gets around
that particular bug, plus one problem with a null check on a Realm
collection.
2023-01-10 15:35:59 -08:00
Chris
516b1a487d Create more robust taxon display name component - #320 (#334)
* Add missing dependency

* Fix display taxon name

* Lint

* Add unit tests

* Lint

* Add test file

* Fix bad commits

* Add unit tests

* Lint

* Fix lint

* Lint

* Fix tests

* Fix tests

* Remove console log

* Fix most comments and add test case for subspecies

* Fix lint

* Add common name capitalization

* Fix broken tests

* Fix test
2023-01-06 10:39:38 -08:00
Amanda Bullington
0c4b9a5158 Fixes for API calls, useCurrentUser hook, api token not being fetched (#309)
* Random code cleanup

* Simplify useCurrentUser hook; only fetch messages if current user; closes #272

* Fix padding around login prompt button

* Code cleanup

* Fix projects; display search and tabs separately

* Remove log
2022-12-21 13:35:41 -08:00
Amanda Bullington
0d69fe1568 Fetch user locale from server and change language (#255)
* Fetch user from server, set locale in realm and change language with i18next
* Added some Spanish translations so I can see localization working
* config QueryClient with `cacheTime: Infinity` to deal with "Jest did not
  exit" errors

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-12-09 15:51:17 -08:00
Amanda Bullington
4d213bd4c6 Create / update / delete requests with useMutation (#206)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* Use mutations for blocking/muting users, invalidating queries, and refetching settings data
* Add react mutation to create/update/delete api calls
* Use mutation for creating identification on identity/obs detail screens
* Use mutations to update and delete relationships
* Use mutation to revoke authorized apps
* Use mutation for updating user settings
* Fix ids on activity tab; fix safe area view; fix mark viewed
* Limit fields for remote observation api call

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-31 20:39:38 -07:00
Amanda Bullington
c740a06224 Start using Tailwind CSS (#185)
Starts changing styles over to tailwind via nativewind.

* Update node to 16.17.0
* Use styled() to ignore flow errors about className or tw props when styling components with nativewind
* Upgrade realm to make test suite run; set failing test in Explore as todo
* Add workaround for getting pods to run with XCode 14
* Fix for loading remote obs with infinite scroll
* Add styling section to README
* Use IconButton from rn-paper to make buttons more responsive to press
* Add caret next to camera roll album picker
* Fixed broken addition of gallery photos to existing observation
* Removed flatlist from scrollview on ProjectDetails (apparently not allowed?)
* Moved border style from Image to container in PhotoCarousel (border color
  not allowed for images?)

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 17:15:55 -07:00
Amanda Bullington
e81894d406 Use authenticated queries for fetch/search requests (#195)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade Realm to 11.0.0-rc.0, most recent version that will work with RN 0.68.2
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* ObsDetail wasn't showing the edit button for obs created while signed out
* simplified ObsEditHeader so it takes a full observation instead of relying
  on the ObsEditContext
* ObsEdit now accepts an obs UUID as a param and loads that if the context
  doesn't have a current obs
* null checks for API methods, mostly to prevent requests that won't work b/c
  of missing params

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 13:01:04 -07:00
Amanda Bullington
c4d9cd4dc6 Use babel-plugin-module-resolver (#188)
* Add alias and update eslint/flow to resolve modules

* Update aliases for components and api

* Add other src directories to module resolver aliases
2022-10-07 10:20:55 -07:00
Amanda Bullington
337d812ab9 UI updates to bottom sheet (#181)
* Changes My Observations upload bottom sheet from modal to non-modal
* Give flatlist container a minHeight to make bottom sheet snap correctly when flatlist has few items
* Mock useLoggedIn hook in tests
* Move useCurrentUser to sharedHooks/ and mock in ObsList test
* Mock useUser hook
* Use useCurrentUser hook on user profile
* Downgrade gesture handler
2022-09-19 14:40:26 -07:00
Ken-ichi
e929764c25 Adopted and enforced code style from other iNat Javascript projects
These rules are largely based on the AirBnB ones, which are not quite standard
for the React Native world, where Prettier seems to be more common, but I
think they add a lot of useful checks, and unlike Prettier we can customize
them. This also just makes it easier for people on the iNat team to work on
the mobile app.

Some specific changes:

* Added eslint-plugin-react-hooks to eslint rules
* Added eslint-plugin-simple-import-sort to eslint rules
* Bugfix: could not import photo from gallery
* Added support for react-native/no-inline-styles eslint rule
* useUser should not bother fetching a user for a blank userId
2022-07-13 13:55:59 -07:00
Amanda Bullington
1ebf4b951d Bug fixes from beta 0.0.1 (#75)
* Add exception handler library; fix computer vision results

* Create loggedIn hook to check whether user is logged in before cv suggestions or upload

* Create user profile card on MyObs

* Update packages

* Add text for camera permissions denied

* Remove log

* Upgrade react native on iOS

* Add vendor file for ruby gems to gitignore

* Remove vendor file from github

* Update react native for android

* Add plural example to fluent; create TranslatedText component to render translations

* Add translations and update camera roll screens

* Small changes to uploader flow; add date/time picker

* Separate explore into landing screen and view screen

* Show total number of observations, explore

* Clean up styling and add details for grid view; banner for total observations in explore

* Add checkboxes for status, quality grade, media filters

* Add a lot of explore filters

* Show months in Explore filters

* Create About screen; sync package.json version using react native version

* Get explore filters in mostly working condition

* Observations download after login; clear login screen after nav; closes #62 and #60

* Allow separating photos if at least 1 combined photo obs is selected; closes #68

* Fix auth tests; add user id

* Pop text input above keyboard to address #66

* Lint cleanup

* Create bottom modal for user tapping back button on ObsEdit

* Check permissions on android only, camera

* Keep trying to get android camera working

* Change version number to 0.1.0
2022-04-01 15:46:51 -07:00
Nick McConnell
d97310dfd5 Fixes Projects.test.js false positive problem (#54) 2022-03-17 14:04:29 -07:00
Amanda Bullington
c5c50b3c24 Merge projects / project details into main (#38)
* Create projects screen which searches projects and changes API params on button press

* Create project details screen which makes an API call by project id

* Clean up project code; get one project test passing

* Basic styling for project details; add project observations grid

* Add testing for project details
2022-01-12 14:27:51 -08:00