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 url: url
json: json:
lines: docLines lines: docLines
headers: source: source
"x-sl-update-source": source
logger.log project_id:project_id, doc_id: doc_id, source: source, "setting doc in document updater" logger.log project_id:project_id, doc_id: doc_id, source: source, "setting doc in document updater"
request.post body, (error, res, body)-> request.post body, (error, res, body)->
timer.done() timer.done()

View file

@ -210,10 +210,10 @@ define [
_bindToShareJsDocEvents: () -> _bindToShareJsDocEvents: () ->
@doc.on "error", (error, meta) => @_onError error, meta @doc.on "error", (error, meta) => @_onError error, meta
@doc.on "externalUpdate", () => @doc.on "externalUpdate", (update) =>
@ide.pushEvent "externalUpdate", @ide.pushEvent "externalUpdate",
doc_id: @doc_id doc_id: @doc_id
@trigger "externalUpdate" @trigger "externalUpdate", update
@doc.on "remoteop", () => @doc.on "remoteop", () =>
@ide.pushEvent "remoteop", @ide.pushEvent "remoteop",
doc_id: @doc_id 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." "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( @ide.showGenericMessageModal(
"Document Updated Externally" "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." "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: () -> getCurrentDocId: () ->
@$scope.editor.open_doc_id @$scope.editor.open_doc_id
startIgnoringExternalUpdates: () ->
@_ignoreExternalUpdates = true
stopIgnoringExternalUpdates: () ->
@_ignoreExternalUpdates = false

View file

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

View file

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