       @fs.root.getFile "commands.json", { create: true }, ((fileEntry) =>
         @fileEntry = fileEntry
         fileEntry.file @readFile.bind(this), @onLoadError.bind(this)
-      ), console.log.bind(console, "error loading file")
+      ), console.log.bind(console, "Error loading file")
 
     sync: ->
-      return _.defer @trigger.bind(this, "synced") if @commands
+      params = {}
+      params["updatedSince"] = @lastSync if @lastSync
 
-      $.getJSON "#{Config.API_URL}/commands", (response) =>
-        @commands = response
-        @trigger "synced"
-        @storeCommands()
+      $.getJSON("#{Config.API_URL}/commands", params)
+        .success((response) =>
+          if response.length
+            @commands = response.concat @commands
+            @lastSync = _.last(response).updatedAt # Response is sorted by
+                                                   # ascending updatedAt
+            @storeCommands()
+
+          @trigger "synced"
+        )
+        .error(console.log.bind(console, "Error fetching commands"))
 
     requestFileSystem: (
       window.requestFileSystem ||

      reader.readAsText file
      self = this
      reader.onloadend = ->
        self.commands = JSON.parse(@result) if @result
        self.trigger "initialised"

    storeCommands: ->
      @fileEntry.createWriter ((fileWriter) =>
        blob = new Blob [JSON.stringify @commands], type: "application/json"

        fileWriter.write blob
        fileWriter.onwriteend = console.log.bind console, "Successfully wrote file"
        fileWriter.onerror = console.log.bind console, "Error writing file"
      ), console.log.bind(console, "Error creating writer")


  Config
) ->
  class CommandStore
    commands: []
    lastSync: null
    fileEntry: null

    constructor: ->
      _.extend this, Backbone.Events
      @requestFileSystem(
