Skip to content

Commit eb1db9c

Browse files
Update Most Recent Subtopic Dropdown
- When user stops timer it will update the subtopic dropdown to display the most recent subtopic used - Everything should be updated now and working as intended with the drop downs
1 parent f7c2d15 commit eb1db9c

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ ipcMain.handle('log-time-handler', (req, data) => {
259259
const result = databaseHandler('run', sqlStatement, params);
260260

261261
updateTopicPreviousClock(data.topicID);
262+
updateSubtopicPreviousClock(data.subtopicID);
262263
return result;
263264
});
264265

@@ -271,6 +272,13 @@ function updateTopicPreviousClock(id){
271272
return result;
272273
}
273274

275+
function updateSubtopicPreviousClock(id){
276+
const sqlStatement = `UPDATE subtopics SET previousTime = CURRENT_TIMESTAMP WHERE id = ?`;
277+
const params = [id];
278+
const result = databaseHandler('run', sqlStatement, params);
279+
return result;
280+
}
281+
274282
ipcMain.handle('quick-times-handler', async (req, data) => {
275283
if (!data || !data.request) return;
276284
let times;

src/timer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function startTimer(){
4242
toggleInputsDiv();
4343
}
4444

45-
function stopTimer(){
45+
async function stopTimer(){
4646
logStopTime = Date.now();
4747
timerActive = false;
4848
const logTime = logStopTime - logStartTime;
@@ -69,4 +69,7 @@ function formatTime(milliseconds){
6969

7070
async function logTimeHandler(time){
7171
const result = await api.logTimeHandler({topicID: topicSelect_el.value, subtopicID: subtopicSelect_el.value, project: projectInput_el.value, time});
72+
await getAllActiveTopics();
73+
await getAllActiveSubtopics();
74+
await populateSubtopicSelect(topicSelect_el.value);
7275
}

0 commit comments

Comments
 (0)