File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
frontend/src/components/DraftCards Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
116116 const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false )
117117 const appStateContext = useContext ( AppStateContext )
118118 const [ charCount , setCharCount ] = useState ( 0 )
119+ const [ wasInitialized , setWasInitialized ] = useState ( false )
119120
120121 if ( ! appStateContext ) {
121122 throw new Error ( 'useAppState must be used within a AppStateProvider' )
@@ -147,13 +148,19 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
147148 }
148149 appStateContext ?. dispatch ( { type : 'UPDATE_SECTION' , payload : { sectionIdx : sectionIdx , section : updatedSection } } )
149150 const content = updatedSection . content || ''
150- setCharCount ( content . length )
151+
152+ // limit the character count to 2000
153+ if ( content . length > sectionCharacterLimit ) {
154+ updatedSection . content = content . slice ( 0 , sectionCharacterLimit )
155+ }
151156
157+ setCharCount ( content . length )
152158 setIsLoading ( false )
153159 }
154160
155- if ( sectionContent === '' && ! isLoading ) {
161+ if ( sectionContent === '' && ! isLoading && ! wasInitialized ) {
156162 fetchSectionContent ( sectionTitle , sectionDescription )
163+ setWasInitialized ( true )
157164 }
158165
159166 return (
You can’t perform that action at this time.
0 commit comments