class EnClient::UpdateNoteCommand

Attributes

content[RW]
edit_mode[RW]
guid[RW]
notebook_guid[RW]
tag_names[RW]
title[RW]

Public Instance Methods

exec_impl() click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 512
def exec_impl
  Formatter.to_ascii @title, @notebook_guid, @content, *@tag_names

  old_note = DBUtils.get_note dm, @guid

  note = Evernote::EDAM::Type::Note.new
  note.guid = @guid
  if @title
    note.title = @title
  else
    note.title = old_note.title
  end
  note.notebookGuid = @notebook_guid
  note.tagNames = @tag_names
  if @edit_mode
    note.editMode = @edit_mode
  else
    note.editMode = old_note.editMode
  end
  note.content = @content
  set_attribute_and_format_content! note

  server_task do
    result_note = sm.note_store.updateNote sm.auth_token, note
    result_note.editMode = note.editMode
    DBUtils.set_note_and_content dm, result_note, @content
    reply = UpdateNoteReply.new

    if result_note.tagGuids
      result_note.tagGuids.each do |guid|
        unless DBUtils.exist_tag_in_cache? dm, guid
          tags = sm.note_store.listTags sm.auth_token
          DBUtils.sync_updated_tags dm, tags
          break
        end
      end
    end

    reply.note = result_note
    shell.reply self, reply
  end
end