Skip to content

Commit

Permalink
Fix quotes on except
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Apr 24, 2024
1 parent 85b33d5 commit 9e66455
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
1 change: 1 addition & 0 deletions assets/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type IconType =
| 'search_outline'
| 'close_modal_button'
| 'red_x'
| 'share_outline'
| 'green_check'
| 'hide_password'
| 'grey_dot'
Expand Down
1 change: 0 additions & 1 deletion src/app/(tabs)/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ function HomeScreen() {
<Text style={[globalStyles.h3, styles.subheading]}>
Recommended For You
</Text>
<ReactionPicker />
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
Expand Down
28 changes: 12 additions & 16 deletions src/app/(tabs)/story/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Ionicons } from '@expo/vector-icons';
import { useLocalSearchParams, router } from 'expo-router';
import { router, useLocalSearchParams } from 'expo-router';
import * as cheerio from 'cheerio';
import React, { useEffect, useState } from 'react';
import {
ActivityIndicator,
FlatList,
ScrollView,
Share,
Text,
TouchableOpacity,
View,
useWindowDimensions,
} from 'react-native';
Expand All @@ -24,7 +23,7 @@ import SaveStoryButton from '../../../components/SaveStoryButton/SaveStoryButton
import ReactionPicker from '../../../components/ReactionPicker/ReactionPicker';
import { fetchStory } from '../../../queries/stories';
import { Story } from '../../../queries/types';
import globalStyles from '../../../styles/globalStyles';
import globalStyles, { fonts } from '../../../styles/globalStyles';
import BackButton from '../../../components/BackButton/BackButton';
import colors from '../../../styles/colors';

Expand Down Expand Up @@ -70,15 +69,7 @@ function StoryScreen() {
console.log(error);
}
};
const htmlContent = story?.excerpt?.html ? story.excerpt.html : '';

// Add the quotation marks after the start of the <p> tag and before the end of the </p> tag
const modifiedExcerpt = htmlContent
.replace(/<p [^>]*>/, match => `${match}&ldquo;`)
.replace('</p>', '&rdquo;</p>');
console.log(typeof htmlContent);

console.log('TESTING CONTENT', htmlContent);
return (
<SafeAreaView style={[globalStyles.tabBarContainer, styles.container]}>
{isLoading ? (
Expand All @@ -90,6 +81,7 @@ function StoryScreen() {
ref={scrollRef}
showsVerticalScrollIndicator={false}
>
<BackButton pressFunction={() => router.back()} />
<View style={styles.container}>
{story?.featured_media ? (
<Image
Expand All @@ -114,7 +106,7 @@ function StoryScreen() {
style={styles.genres}
horizontal
data={story.genre_medium}
keyExtractor={(item, index) => index.toString()} // Add a key extractor for performance optimization
keyExtractor={(_, index) => index.toString()} // Add a key extractor for performance optimization
renderItem={({ item, index }) => (
<View
style={[
Expand All @@ -137,21 +129,25 @@ function StoryScreen() {
</View>

<RenderHTML
source={{ html: modifiedExcerpt }}
source={{ html: `"${cheerio.load(story.excerpt.html ?? "").text()}"` }}
baseStyle={globalStyles.h2}
contentWidth={width}
systemFonts={fonts}
tagsStyles={{ p: globalStyles.h2 }}
ignoredStyles={['color', 'fontSize', 'fontWeight']} // Ignore these inline styles
/>

<RenderHTML source={story.content} baseStyle={styles.story} />
<RenderHTML systemFonts={fonts} source={story.content} contentWidth={width}
baseStyle={styles.story} />

<View style={styles.button_style}>
<Icon type="share_outline" />
<Text style={styles.shareButtonText}>Share Story</Text>
</View>
<Text style={styles.authorProcess}>Author's Process</Text>

<RenderHTML source={story.process} baseStyle={styles.process} />
<RenderHTML systemFonts={fonts} source={story.process} contentWidth={width}
baseStyle={styles.process} />

<View style={styles.author}>
<Image
Expand Down
16 changes: 0 additions & 16 deletions src/queries/stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,6 @@ export async function fetchNewStories(): Promise<StoryCard[]> {
}
}

export async function fetchStoryPreviewById(
storyId: number,
): Promise<StoryPreview[]> {
const { data, error } = await supabase.rpc('curr_story_preview_by_id', {
input_story_id: storyId,
});
if (error) {
console.log(error);
throw new Error(
`An error occured when trying to fetch story preview by ID: ${error}`,
);
} else {
return data;
}
}

export async function fetchStoryPreviewByIds(
storyIds: number[],
): Promise<StoryPreview[]> {
Expand Down

0 comments on commit 9e66455

Please sign in to comment.