Send source of update to doc updater and allow external updates to be ignored in UI

This commit is contained in:
James Allen 2014-10-15 16:37:14 +01:00
parent 1b893ff502
commit 9f1a7c7396
5 changed files with 13 additions and 8 deletions

View file

@ -123,8 +123,7 @@ module.exports = DocumentUpdaterHandler =
url: url
json:
lines: docLines
headers:
"x-sl-update-source": source
source: source
logger.log project_id:project_id, doc_id: doc_id, source: source, "setting doc in document updater"
request.post body, (error, res, body)->
timer.done()

View file

@ -210,10 +210,10 @@ define [
_bindToShareJsDocEvents: () ->
@doc.on "error", (error, meta) => @_onError error, meta
@doc.on "externalUpdate", () =>
@doc.on "externalUpdate", (update) =>
@ide.pushEvent "externalUpdate",
doc_id: @doc_id
@trigger "externalUpdate"
@trigger "externalUpdate", update
@doc.on "remoteop", () =>
@ide.pushEvent "remoteop",
doc_id: @doc_id

View file

@ -84,7 +84,8 @@ define [
"Sorry, this file has gone out of sync and we need to do a full refresh. Please let us know if this happens frequently."
)
sharejs_doc.on "externalUpdate", () =>
sharejs_doc.on "externalUpdate", (update) =>
return if @_ignoreExternalUpdates
@ide.showGenericMessageModal(
"Document Updated Externally"
"This document was just updated externally. Any recent changes you have made may have been overwritten. To see previous versions please look in the history."
@ -98,3 +99,9 @@ define [
getCurrentDocId: () ->
@$scope.editor.open_doc_id
startIgnoringExternalUpdates: () ->
@_ignoreExternalUpdates = true
stopIgnoringExternalUpdates: () ->
@_ignoreExternalUpdates = false

View file

@ -57,7 +57,7 @@ define [
@_handleError(error)
if message?.meta?.type == "external"
@trigger "externalUpdate"
@trigger "externalUpdate", message
catchUp: (updates) ->
for update, i in updates

View file

@ -227,8 +227,7 @@ describe 'Flushing documents :', ->
url: url
json:
lines: @lines
headers:
"x-sl-update-source": @source
source: @source
})
.should.equal true