 @app.factory 'selection', [
-  '$rootScope', '$location', '$http', '$route', 'Library', 'User',
-  ($rootScope,   $location,   $http,   $route,   Library,   User) ->
+  '$rootScope', '$location', '$http', '$route', '$q', 'Library', 'User',
+  ($rootScope,   $location,   $http,   $route,   $q,   Library,   User) ->
 
     $rootScope.$watch (-> Library.current), (lib) ->
       setIds(lib.selection ||= [])

      click: (event, uploadId) ->
        @clear() unless User.me.manual_deselect || event.ctrlKey || event.metaKey

        if (i = @indexOf(uploadId)) != -1
          @ids.splice(i, 1)
        else
          @insert([ uploadId ])

      isSelected: (uploadId) ->
        @indexOf(uploadId) != -1

    setIds = (ids) ->
      service.ids = _.uniq(ids.sort((a, b) -> a - b), true)

    startId = null

    service =
      manualDeselect: (setting) ->
        if setting == 'toggle'
