Don't overwrite description in Suggestions/TaxonSearch (#1916)

* Don't overwrite description in Suggestions/TaxonSearch; closes #1913

* Fix TS

* Remove unused code related to adding/editing comments in Suggestions/TSearch

* Remove test about showing comments on Suggestions
This commit is contained in:
Amanda Bullington
2024-08-06 18:41:54 -07:00
committed by GitHub
parent 0e2b647ff3
commit e0b5d446a2
11 changed files with 15 additions and 131 deletions

View File

@@ -1,16 +1,19 @@
set -e
#!/usr/bin/env bash
set -e
BASELINE_BRANCH=main
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}
# Required for `git switch` on CI
git fetch origin
# Gather baseline perf measurements
git switch "$BASELINE_BRANCH"
npm install --force
npx reassure --baseline
npm install
npm run reassure -- --baseline
# Gather current perf measurements & compare results
git switch --detach -
npm install --force
npm run reassure
npm install
npm run reassure -- --branch

View File

@@ -1,50 +0,0 @@
// @flow
import { useNavigation } from "@react-navigation/native";
import {
INatIconButton,
TextInputSheet
} from "components/SharedComponents";
import type { Node } from "react";
import React, { useEffect, useState } from "react";
import { useTranslation } from "sharedHooks";
import useStore from "stores/useStore";
const AddCommentPrompt = ( ): Node => {
const currentObservation = useStore( state => state.currentObservation );
const updateComment = useStore( state => state.updateComment );
const [showAddCommentSheet, setShowAddCommentSheet] = useState( false );
const synced = currentObservation?.wasSynced !== undefined
&& currentObservation.wasSynced( );
const { t } = useTranslation( );
const navigation = useNavigation( );
useEffect( ( ) => {
const addCommentIcon = ( ) => (
<INatIconButton
icon="edit-comment"
onPress={( ) => setShowAddCommentSheet( true )}
accessibilityLabel={t( "Add-comment" )}
size={25}
/>
);
if ( synced ) {
navigation.setOptions( {
headerRight: addCommentIcon
} );
}
}, [navigation, t, synced] );
return showAddCommentSheet && (
<TextInputSheet
handleClose={( ) => setShowAddCommentSheet( false )}
headerText={t( "ADD-OPTIONAL-COMMENT" )}
confirm={updateComment}
/>
);
};
export default AddCommentPrompt;

View File

@@ -1,34 +0,0 @@
// @flow
import {
Body3, INatIcon
} from "components/SharedComponents";
import {
View
} from "components/styledComponents";
import type { Node } from "react";
import React from "react";
import { useTranslation } from "sharedHooks";
import useStore from "stores/useStore";
const CommentBox = ( ): Node => {
const comment = useStore( state => state.comment );
const { t } = useTranslation( );
return comment && comment.length > 0 && (
<>
<Body3 className="my-5 mx-8">
{t( "Your-identification-will-be-posted-with-the-following-comment" )}
</Body3>
<View className="bg-lightGray mx-6 p-5 rounded-lg flex-row items-center">
<INatIcon
name="add-comment-outline"
size={22}
/>
<Body3 className="ml-4 shrink">{ comment }</Body3>
</View>
</>
);
};
export default CommentBox;

View File

@@ -9,8 +9,6 @@ import React from "react";
import { useTheme } from "react-native-paper";
import { useTranslation } from "sharedHooks";
import AddCommentPrompt from "./AddCommentPrompt";
import CommentBox from "./CommentBox";
import ObsPhotoSelectionList from "./ObsPhotoSelectionList";
interface Props {
@@ -37,7 +35,6 @@ const SuggestionsHeader = ( {
return (
<>
<AddCommentPrompt />
<View className="mx-5">
<ObsPhotoSelectionList
photoUris={photoUris}
@@ -74,7 +71,6 @@ const SuggestionsHeader = ( {
</View>
</Pressable>
)}
<CommentBox />
</>
);
};

View File

@@ -16,8 +16,6 @@ import { useTaxonSearch, useTranslation } from "sharedHooks";
import { getShadowForColor } from "styles/global";
import colors from "styles/tailwindColors";
import AddCommentPrompt from "./AddCommentPrompt";
import CommentBox from "./CommentBox";
import useNavigateWithTaxonSelected from "./hooks/useNavigateWithTaxonSelected";
const DROP_SHADOW = getShadowForColor( colors.darkGray, {
@@ -50,8 +48,6 @@ const TaxonSearch = ( ): Node => {
return (
<ViewWrapper>
<AddCommentPrompt />
<CommentBox />
<View
className="bg-white px-6 pt-2 pb-8"
style={DROP_SHADOW}

View File

@@ -1,22 +1,21 @@
// @flow
import { useNavigation, useRoute } from "@react-navigation/native";
import { useEffect } from "react";
import useStore from "stores/useStore";
const useNavigateWithTaxonSelected = (
// Navgiation happens when a taxon was selected
selectedTaxon: ?Object,
// Navigation happens when a taxon was selected
selectedTaxon: Object | null | undefined,
// After navigation we need to unselect the taxon so we don't have
// mysterious background nonsense happening after this screen loses focus
unselectTaxon: Function,
options: Object
options: {
vision: boolean
}
) => {
const navigation = useNavigation( );
const { params } = useRoute( );
const { entryScreen } = params;
const currentObservation = useStore( state => state.currentObservation );
const comment = useStore( state => state.comment );
const updateObservationKeys = useStore( state => state.updateObservationKeys );
const vision = options?.vision;
@@ -31,8 +30,7 @@ const useNavigateWithTaxonSelected = (
} else {
updateObservationKeys( {
owners_identification_from_vision: vision,
taxon: selectedTaxon,
description: comment
taxon: selectedTaxon
} );
}
@@ -65,7 +63,6 @@ const useNavigateWithTaxonSelected = (
// If we've navigated, there's no need to run this effect again
unselectTaxon( );
}, [
comment,
currentObservation?.uuid,
entryScreen,
navigation,

View File

@@ -36,7 +36,6 @@ Add-agreement = Add agreement
ADD-AN-ID = ADD AN ID
Add-an-ID-Later = Add an ID Later
ADD-COMMENT = ADD COMMENT
Add-comment = Add comment
Add-Date-Time = Add Date/Time
# Label for a button that adds a vote of disagreement
Add-disagreement = Add disagreement
@@ -1163,7 +1162,6 @@ You-need-log-in-to-do-that = You need to log in to do that.
You-will-see-notifications = Youll see notifications here once you log in & upload observations.
Your-donation-to-iNaturalist = Your donation to iNaturalist supports the improvement and stability of the mobile apps and website that connects millions of people to nature and enables the protection of biodiversity worldwide!
Your-email-is-confirmed = Your email is confirmed! Please log in to continue.
Your-identification-will-be-posted-with-the-following-comment = Your identification will be posted with the following comment:
Your-location-uncertainty-is-over-x-km = Your location uncertainty is over { $x } km, which is too high to be helpful to identifiers. Edit the location and zoom in until the accuracy circle turns green and is centered on where you observed the organism.
Youre-always-in-control-of-the-location-privacy = Youre always in control of the location privacy of every observation you create.
# Text prompting the user to open Settings to grant permission after

View File

@@ -28,7 +28,6 @@
"ADD-AN-ID": "ADD AN ID",
"Add-an-ID-Later": "Add an ID Later",
"ADD-COMMENT": "ADD COMMENT",
"Add-comment": "Add comment",
"Add-Date-Time": "Add Date/Time",
"Add-disagreement": {
"comment": "Label for a button that adds a vote of disagreement",
@@ -1465,7 +1464,6 @@
"You-will-see-notifications": "Youll see notifications here once you log in & upload observations.",
"Your-donation-to-iNaturalist": "Your donation to iNaturalist supports the improvement and stability of the mobile apps and website that connects millions of people to nature and enables the protection of biodiversity worldwide!",
"Your-email-is-confirmed": "Your email is confirmed! Please log in to continue.",
"Your-identification-will-be-posted-with-the-following-comment": "Your identification will be posted with the following comment:",
"Your-location-uncertainty-is-over-x-km": "Your location uncertainty is over { $x } km, which is too high to be helpful to identifiers. Edit the location and zoom in until the accuracy circle turns green and is centered on where you observed the organism.",
"Youre-always-in-control-of-the-location-privacy": "Youre always in control of the location privacy of every observation you create.",
"Youve-denied-permission-prompt": {

View File

@@ -36,7 +36,6 @@ Add-agreement = Add agreement
ADD-AN-ID = ADD AN ID
Add-an-ID-Later = Add an ID Later
ADD-COMMENT = ADD COMMENT
Add-comment = Add comment
Add-Date-Time = Add Date/Time
# Label for a button that adds a vote of disagreement
Add-disagreement = Add disagreement
@@ -1163,7 +1162,6 @@ You-need-log-in-to-do-that = You need to log in to do that.
You-will-see-notifications = Youll see notifications here once you log in & upload observations.
Your-donation-to-iNaturalist = Your donation to iNaturalist supports the improvement and stability of the mobile apps and website that connects millions of people to nature and enables the protection of biodiversity worldwide!
Your-email-is-confirmed = Your email is confirmed! Please log in to continue.
Your-identification-will-be-posted-with-the-following-comment = Your identification will be posted with the following comment:
Your-location-uncertainty-is-over-x-km = Your location uncertainty is over { $x } km, which is too high to be helpful to identifiers. Edit the location and zoom in until the accuracy circle turns green and is centered on where you observed the organism.
Youre-always-in-control-of-the-location-privacy = Youre always in control of the location privacy of every observation you create.
# Text prompting the user to open Settings to grant permission after

View File

@@ -6,7 +6,6 @@ import Sound from "realmModels/Sound";
const DEFAULT_STATE = {
cameraRollUris: [],
comment: "",
currentObservation: {},
currentObservationIndex: 0,
evidenceToAdd: [],
@@ -145,7 +144,6 @@ const createObservationFlowSlice = ( set, get ) => ( {
),
firstObservationDefaults: options?.firstObservationDefaults
} ) ),
updateComment: newComment => set( { comment: newComment } ),
updateObservations: updatedObservations => set( state => ( {
observations: updatedObservations.map( observationToJSON ),
currentObservation: observationToJSON( updatedObservations[state.currentObservationIndex] )

View File

@@ -72,22 +72,6 @@ describe( "Suggestions", ( ) => {
} );
} );
it( "shows comment section if observation has comment", ( ) => {
useStore.setState( {
comment: "This is a test comment"
} );
renderComponent( <Suggestions
suggestions={{
...initialSuggestions,
otherSuggestions: mockSuggestionsList
}}
/> );
const commentSection = screen.getByText(
i18next.t( "Your-identification-will-be-posted-with-the-following-comment" )
);
expect( commentSection ).toBeVisible( );
} );
it( "should display empty text if no suggestions are found", ( ) => {
renderComponent( <Suggestions suggestions={initialSuggestions} /> );
const emptyText = i18next