Skip to content

Commit

Permalink
fixed recentlyViewed Stories stacking when selected from that array, …
Browse files Browse the repository at this point in the history
…recentSearches now work when pressable
  • Loading branch information
Marcos Hernandez committed Dec 1, 2023
1 parent b75b71a commit 78fb212
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/app/(tabs)/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ function SearchScreen() {
setRecentStory([]);
};

const searchResultStacking = (searchString: string) => {
const searchResultStacking = (
searchString: string,
searchResults: number,
) => {
if (searchString !== '') {
const maxArrayLength = 5;

Expand All @@ -119,7 +122,7 @@ function SearchScreen() {

const result: RecentSearch = {
value: searchString,
numResults: searchResults.length,
numResults: searchResults,
};

newRecentSearches.splice(0, 0, result);
Expand Down Expand Up @@ -170,7 +173,10 @@ function SearchScreen() {
onChangeText={text => searchFunction(text)}
value={search}
onSubmitEditing={searchString => {
searchResultStacking(searchString.nativeEvent.text);
searchResultStacking(
searchString.nativeEvent.text,
searchResults.length,
);
}}
/>
</View>
Expand Down Expand Up @@ -204,8 +210,9 @@ function SearchScreen() {
value={item.value}
numResults={item.numResults}
pressFunction={() => {
null;
}} // add functionality
searchFunction(item.value);
searchResultStacking(item.value, item.numResults);
}}
/>
))}
</View>
Expand Down

0 comments on commit 78fb212

Please sign in to comment.