 
 				Meteor.call 'sendMessage', msgObject
 				
+		# If edited message was emptied we ask for deletion
 		else if this.editing.element
-			element = this.editing.element
-			message = this.getMessageOfElement(element)
+			message = this.getMessageById this.editing.id
+
+			# Restore original message in textbox in case delete is canceled
 			this.resetToDraft this.editing.id
+
 			this.confirmDeleteMsg message
 
 	confirmDeleteMsg: (message) ->

		if k is 27 # Escape
			if this.editing.index?
				record = this.getMessageDraft(this.editing.id)
				if this.input.value is record?.original
					this.clearCurrentDraft()
					this.clearEditing()
				else
					this.resetToDraft this.editing.id

				event.preventDefault()
				event.stopPropagation()

	edit: (element, index) ->
		index = this.getEditingIndex(element) if not index?

		message = this.getMessageById element.getAttribute("id")

		hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid)
		editAllowed = RocketChat.settings.get 'Message_AllowEditing'
		editOwn = message?.u?._id is Meteor.userId()
