    on timer stopped, send time entry.
   ###
   $scope.$on 'timer-stopped', (e, time) ->
-    postEntry(time.minutes)
+    trackedTime = time
+    if not state.isTracking
+      postEntry(time.minutes)
 
 
   ###

  $scope.tickets = []
  $scope.selectedTicket = []


  ###
   Initialize.


  ###
   change post mode.
   if tracking, restore tracked time.
  ###
  $scope.changeMode = () ->
    if $scope.mode is "auto"
      if state.isTracking
        $scope.$broadcast 'timer-stop'
      $scope.mode = "manual"
    else
      $scope.mode = "auto"
      if state.isTracking
        # wait for complete switching
        $timeout () ->
          $scope.$broadcast 'timer-start', new Date() - trackedTime.millis
        , SWITCHING_TIME


  ###
