Skip to content

Commit

Permalink
Small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Apr 7, 2024
1 parent ea44cc5 commit 2d29e69
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 36 deletions.
11 changes: 8 additions & 3 deletions src/app/(tabs)/author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../../../queries/authors';
import { Author, StoryPreview } from '../../../queries/types';
import globalStyles from '../../../styles/globalStyles';
import * as cheerio from 'cheerio';

function AuthorScreen() {
const [authorInfo, setAuthorInfo] = useState<Author>();
Expand Down Expand Up @@ -45,6 +46,10 @@ function AuthorScreen() {
})();
}, [author]);

const getTextFromHtml = (text: string) => {
return cheerio.load(text).text().trim()
}

return (
<SafeAreaView style={[globalStyles.tabBarContainer, { marginHorizontal: -8 }]}>
{isLoading ? (
Expand All @@ -69,7 +74,7 @@ function AuthorScreen() {
numberOfLines={2}
style={globalStyles.h1}
>
{authorInfo.name}
{getTextFromHtml(authorInfo.name)}
</Text>
{authorInfo?.pronouns && (
<Text style={[globalStyles.subHeading2, styles.pronouns]}>
Expand All @@ -84,7 +89,7 @@ function AuthorScreen() {

{authorInfo?.bio && (
<>
<Text style={globalStyles.body1}>{decode(authorInfo.bio)}</Text>
<Text style={globalStyles.body1}>{getTextFromHtml(authorInfo.bio)}</Text>
<HorizontalLine />
</>
)}
Expand All @@ -97,7 +102,7 @@ function AuthorScreen() {
Artist's Statement
</Text>
<Text style={globalStyles.body1}>
{decode(authorInfo.artist_statement)}
{getTextFromHtml(authorInfo.artist_statement)}
</Text>
<HorizontalLine />
</>
Expand Down
34 changes: 11 additions & 23 deletions src/app/(tabs)/genre/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ function GenreScreen() {
genreName: string;
}>();

// console.log('passing in genreId params:', genreId);
// console.log('testing passing in genreType', genreType);
// console.log('testing genreName', genreName);
useEffect(() => {
console.log(`Rendering: ${genreId}, ${genreType}, ${genreName}`);
}, []);

useEffect(() => {
const checkTopic = (preview: StoryPreview): boolean => {
if (preview == null || preview.topic == null) return false;
Expand Down Expand Up @@ -131,19 +124,16 @@ function GenreScreen() {
setSubgenres(getSubgenres(genreStoryData));

if (genreType == GenreType.PARENT) {
console.log(
'running if check on genreType, populating usestate with all data',
);
const allStoryIds = getAllStoryIds(genreStoryData);
setGenreStoryIds(allStoryIds);
setSelectedSubgenre('All'); //if user clicks see all, selected should be 'ALL'
setGenreStoryIds(getAllStoryIds(genreStoryData));
} else if (genreType == GenreType.SUBGENRE) {
setSelectedSubgenre(genreName || ''); //if user clicks a specific genre, selected should be genreName

const filteredStoryIds = filterStoriesBySubgenreName(
genreName || '',
genreStoryData,
);
setGenreStoryIds(filteredStoryIds);
setSelectedSubgenre(genreName || ''); //if user clicks a specific genre, selected should be genreName

setLoading(false);
}
Expand Down Expand Up @@ -194,7 +184,7 @@ function GenreScreen() {
{subgenres.map((subgenre, index) => (
<TouchableOpacity
onPress={() => filterBySubgenre(subgenre)} //onPress will trigger the filterBySubgenre function
style={{ marginRight: 40 }}
style={{ paddingHorizontal: 20, paddingTop: 5 }}
key={index}
>
<Text
Expand All @@ -210,19 +200,17 @@ function GenreScreen() {
};

const renderGenreHeading = () => {
console.log(`Selected: ${selectedSubgenre}, mainGenre: ${mainGenre}`);

return (
<View>
<Text style={[globalStyles.h1, { marginTop: 15 }]}>
{selectedSubgenre === 'All' ? mainGenre : selectedSubgenre}
</Text>
<Text style={[globalStyles.subHeading1]}>
{' '}
Subheading about{' '}
{selectedSubgenre === 'All' ? mainGenre : selectedSubgenre}
...Include Later?
</Text>
{/* <Text style={[globalStyles.subHeading1]}> */}
{/* {' '} */}
{/* Subheading about{' '} */}
{/* {selectedSubgenre === 'All' ? mainGenre : selectedSubgenre} */}
{/* ...Include Later? */}
{/* </Text> */}
</View>
);
};
Expand Down Expand Up @@ -315,7 +303,7 @@ function GenreScreen() {
/>

{useMemo(renderGenreHeading, [selectedSubgenre, mainGenre])}
{useMemo(renderGenreScrollSelector, [subgenres])}
{useMemo(renderGenreScrollSelector, [subgenres, selectedSubgenre])}
</View>

<View style={[styles.dropdownContainer, styles.firstDropdown]}>
Expand Down
5 changes: 1 addition & 4 deletions src/app/(tabs)/genre/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const styles = StyleSheet.create({
color: '#EB563B',
textDecorationLine: 'underline',
},

container: {
paddingHorizontal: 24,
width: '100%',
Expand All @@ -19,10 +18,8 @@ const styles = StyleSheet.create({
paddingTop: 15,
},
scrollViewContainer: {
marginTop: 30,
marginBottom: 15,
marginVertical: 15,
width: '100%',
// paddingBottom: 60,
},
noStoriesText: {
fontSize: 20,
Expand Down
10 changes: 4 additions & 6 deletions src/app/(tabs)/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { router } from 'expo-router';
import { useEffect, useState } from 'react';
import { Pressable, ScrollView, Text, View } from 'react-native';
import { ActivityIndicator, Pressable, ScrollView, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';

import styles from './styles';
Expand Down Expand Up @@ -54,15 +54,13 @@ function HomeScreen() {
});
}, [user]);

if (loading) {
return <ActivityIndicator />
}
return (
<SafeAreaView
style={[globalStyles.tabBarContainer, { marginLeft: -8, marginRight: -32 }]}
>
{loading && (
<View style={styles.loading}>
<Text>Loading</Text>
</View>
)}
<ScrollView
horizontal={false}
showsVerticalScrollIndicator={false}
Expand Down

0 comments on commit 2d29e69

Please sign in to comment.