Skip to content

Commit 07bbdae

Browse files
author
Bernhard Dorn
committed
Work description does stick after closing app / browser.
1 parent 613378b commit 07bbdae

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "JiraTime",
4-
"version": "1.3.0",
4+
"version": "1.3.1",
55
"description": "Simple Jira Time Tracking for Developers. By yours truly Bernhard Dorn.",
66
"author": "Bernhard Dorn",
77
"action": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jiratime",
33
"private": true,
4-
"version": "1.3.0",
4+
"version": "1.3.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/components/TicketItem.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)