@@ -77,12 +77,29 @@ export const TicketItem = ({
7777} : TicketItemProps ) => {
7878 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
7979 const [ manualTime , setManualTime ] = useState ( "" ) ;
80- const [ description , setDescription ] = useState ( "" ) ;
80+
81+ // Load initial description from local storage
82+ const getStorageKey = ( ) => `jira_desc_draft_${ ticket . id } ` ;
83+
84+ const [ description , setDescription ] = useState ( ( ) => {
85+ return localStorage . getItem ( getStorageKey ( ) ) || "" ;
86+ } ) ;
87+
8188 const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
8289 const [ liveDuration , setLiveDuration ] = useState ( "" ) ;
8390
8491 const isTimerRunning = activeTimer ?. ticketId === ticket . id ;
8592
93+ // Update local storage when description changes
94+ useEffect ( ( ) => {
95+ const key = getStorageKey ( ) ;
96+ if ( description ) {
97+ localStorage . setItem ( key , description ) ;
98+ } else {
99+ localStorage . removeItem ( key ) ;
100+ }
101+ } , [ description , ticket . id ] ) ;
102+
86103 // Live timer update
87104 useEffect ( ( ) => {
88105 let interval : number ;
@@ -120,8 +137,12 @@ export const TicketItem = ({
120137 }
121138
122139 await addWorklog ( settings , ticket . id , manualTime , description ) ;
140+
141+ // Clear local storage and state upon success
123142 setManualTime ( "" ) ;
124143 setDescription ( "" ) ;
144+ localStorage . removeItem ( getStorageKey ( ) ) ;
145+
125146 onRefresh ( ) ;
126147 // Optional: Show success feedback
127148 } catch ( error ) {
@@ -150,7 +171,11 @@ export const TicketItem = ({
150171
151172 await addWorklog ( settings , ticket . id , seconds , description ) ;
152173 onStopTimer ( ) ;
174+
175+ // Clear description and local storage
153176 setDescription ( "" ) ;
177+ localStorage . removeItem ( getStorageKey ( ) ) ;
178+
154179 onRefresh ( ) ;
155180 } catch ( error ) {
156181 console . error ( error ) ;
0 commit comments