Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Fix #21. Add ability to start with wrong credentials and not crash th…
Browse files Browse the repository at this point in the history
…e workflow
  • Loading branch information
godbout committed Jan 7, 2019
1 parent ff99a12 commit 1355788
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/Harvest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ public function generateTimer($description, $projectId, $taskId)
public function getOnlineData()
{
$data = [];
$data['projects'] = $this->timerAction('get_projects', 'projects');
$data['tasks'] = $this->timerAction('get_tags', 'tasks');

$projects = $this->timerAction('get_projects', 'projects');

if ($projects !== false) {
$data['projects'] = $projects;
}

$tasks = $this->timerAction('get_tags', 'tasks');

if ($tasks !== false) {
$data['tasks'] = $tasks;
}

return $data;
}
Expand Down
10 changes: 9 additions & 1 deletion src/Toggl.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ public function generateTimer($description, $projectId, $tagData)
*/
public function getOnlineData()
{
return $this->timerAction('get_online_data', 'me?with_related_data=true');
$data = [];

$togglData = $this->timerAction('get_online_data', 'me?with_related_data=true');

if ($togglData !== false) {
$data = $togglData;
}

return $data;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/WorkflowHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ private function syncServiceOnlineDataToLocalCache($service)
{
$data = $this->$service->getOnlineData();

$this->saveServiceDataCache($service, $data);

if (empty($data) === true) {
return $this->getNotificationForService($service, 'data', false);
return $this->getNotificationForService($service, 'cache', false);
}

$this->saveServiceDataCache($service, $data);

return $this->getNotificationForService($service, 'data', true);
return $this->getNotificationForService($service, 'cached', true);
}
}

0 comments on commit 1355788

Please sign in to comment.