This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with wrong harvest ID being deleted after UNDO
The issue was that when we started a new timer just for toggl, the harvest ID (other services) were not initialized back to null, while they should. Those IDs in the workflow configuration file are just to handle the UNDO functionality and should reflect the status of the last ran timer through the workflow. If only one service is started, all the other ones IDs have to be back to null.
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
commands/time (Guillaume’s iMac's conflicted copy 2017-04-13).php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
require 'AlfredTime.class.php'; | ||
|
||
$alfredTime = new AlfredTime; | ||
|
||
$query = getenv('description'); | ||
$message = ''; | ||
|
||
if (substr($query, 0, 6) === 'config') { | ||
$alfredTime->generateDefaultConfigurationFile(); | ||
exec('open "' . getenv('alfred_workflow_data') . '/config.json"'); | ||
} elseif (substr($query, 0, 4) === 'sync') { | ||
$message = $alfredTime->syncOnlineDataToLocalCache(); | ||
} elseif (substr($query, 0, 5) === 'edit') { | ||
exec('open "' . getenv('alfred_workflow_data') . '/config.json"'); | ||
} elseif (substr($query, 0, 4) === 'undo') { | ||
$message = $alfredTime->UndoTimer(); | ||
} elseif (substr($query, 0, 6) === 'delete') { | ||
/** | ||
* For now, only handle Toggl | ||
*/ | ||
$timerData = json_decode(getenv('timer_data'), true); | ||
$message = $alfredTime->deleteTimer($timerData['id']); | ||
} elseif (substr($query, 0, 8) === 'continue') { | ||
$timerData = json_decode(getenv('timer_data'), true); | ||
$project = ['toggl' => $timerData['pid']]; | ||
$tags = empty($timerData['tags']) === true ? [] : $timerData['tags']; | ||
$tag = ['toggl' => implode(', ', $tags)]; | ||
$message = $alfredTime->startTimer($timerData['description'], $project, $tag); | ||
} elseif (substr($query, 0, 6) === 'start ') { | ||
$description = substr($query, 6); | ||
|
||
/** | ||
* For now, only handle Toggl projects and tags | ||
*/ | ||
$project = [ | ||
'toggl' => getenv('project_id'), | ||
]; | ||
|
||
$tag = [ | ||
'toggl' => getenv('tag_name') | ||
]; | ||
|
||
$message = $alfredTime->startTimer($description, $project, $tag); | ||
} elseif (substr($query, 0, 14) === 'start_default ') { | ||
$description = substr($query, 14); | ||
$message = $alfredTime->startTimerWithDefaultOptions($description); | ||
} elseif (substr($query, 0, 4) === 'stop') { | ||
$message = $alfredTime->stopRunningTimer(); | ||
} | ||
|
||
echo $message; |