             $scope.nextVideo()
 
     getNextPost = ->
+        if $scope.currentPost?
+            $scope.history.push $scope.currentPost
         $scope.posts.shift()
 
     $scope.nextVideo = ->


    $scope.posts = null
    $scope.currentPost = null

    validPost = (post) ->
        # when switching subreddits,


        $youtube.player.playVideo()

    setURL = (subreddit, post={}) ->
        # update 'v' in query string
        # https://github.com/angular-ui/ui-router/wiki/Quick-Reference#state-1
        $state.go 'subreddit', {
            r: subreddit
            v: post.id
        }, {
            location: true
            reload: false
            notify: false
        }

    $scope.$on 'redditelly.post.change', ->
        setURL $stateParams.r, $scope.currentPost

    $scope.preventDefault = (e) ->
        e.preventDefault()
]
