Skip to content

Commit

Permalink
Fix stopping from command line fixes and closes #57
Browse files Browse the repository at this point in the history
  • Loading branch information
olpeh committed Jan 28, 2018
1 parent f6e2ebf commit fdfa8d7
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,31 @@ Page {
}

if (appState.arguments.stopFromCommandLine) {
// var description = "Automatically saved from command line"
// var project = settings.getDefaultProjectId()
// var taskId = "0"

// TODO: Change the format
// var dateString = helpers.dateToDbDateString(new Date())

// Log.info("AutoSaving: " + uid + "," + dateString + "," + startTime.format("H:mm") + "," + endTime.format("H:mm") + "," + duration + "," + project + "," + description + "," + breakDuration + "," + taskId)

// var values = {
// "dateString": dateString,
// "startTime": startTime.format("H:mm"),
// "endTime": endTime.format("H:mm"),
// "duration": duration,
// "project": project,
// "description": description,
// "breakDuration": breakDuration,
// "taskId": taskId
// }

// if(db.saveHourRow(values)) {
// refreshState()
// } else {
// banner.notify("Error when saving!")
// }
var startMoment = moment(appState.timerStartTime)
var endMoment = moment()

var values = {
"date": startMoment.format("YYYY-MM-DD"),
"startTime": startMoment.format("HH:mm"),
"endTime": endMoment.format("HH:mm"),
// For legacy reasons
"duration": helpers.millisecondsToHours(appState.timerDuration),
"project": settings.getDefaultProjectId(),
"description": "Automatically saved from command line",
// For legacy reasons
"breakDuration": helpers.millisecondsToHours(appState.breakTimerDuration),
"taskId": "0"
};

Log.info("Trying to save automatically: " + JSON.stringify(values));

if(db.saveHourRow(values)) {
// Try to avoid saving multiple times etc.
stopFromCommandLine = false
firstPage.refreshState()
} else {
banner.notify("Error when saving!")
}
} else {
if (fromCover && pageStack.depth > 1) {
pageStack.replaceAbove(appWindow.firstPage,Qt.resolvedUrl("../pages/Add.qml"), { fromTimer: true, fromCover: fromCover })
Expand Down Expand Up @@ -523,7 +523,7 @@ Page {
// TODO: Why is this here?
if(appState.timerRunning && appState.arguments.stopFromCommandLine) {
banner.notify(qsTr("Timer stopped by command line argument"))
stop()
stopTimer()
pageStack.push(Qt.resolvedUrl("All.qml"), {dataContainer: root, section: qsTr("Today")})
}
}
Expand Down

0 comments on commit fdfa8d7

Please sign in to comment.