   # ------------------------------------------------------------------------------------------------------------------
   # TODO prevent multipal duplicated requests
   vm.refresh_all_notes = ->
-    apiClient.notes.all (data) ->
-      # TODO handle failure
-      vm.all_notes = data['notes']
+    # TODO handle failure
+    noteManager.load_remote_notes().then (data) ->
+        vm.all_notes = data['notes']
 
   vm.load_note = (guid) ->
     # check if the note to be loaded is already current note

# ----------------------------------------------------------------------------------------------------------------------
# Service: noteManager
# ----------------------------------------------------------------------------------------------------------------------
markever.factory 'noteManager', ['apiClient', (apiClient) -> new class NoteManager

  # Status of a note:
  # 1. new: note with a generated guid, not attached to remote


  # ------------------------------------------------------------
  # Load remote note list to update local notes info
  # return: promise
  # ------------------------------------------------------------
  load_remote_notes: =>
    # fetch remote notes
    # TODO handle failure
    return apiClient.notes.all()
      .$promise.then (data) =>
        #@_merge_remote_notes(data['notes'])
        return data

  # ------------------------------------------------------------
  # merge remote note list into local note list
