diff --git a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee index 9449c68af9..b7760b40c5 100644 --- a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee +++ b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee @@ -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() diff --git a/services/web/public/coffee/ide/editor/Document.coffee b/services/web/public/coffee/ide/editor/Document.coffee index b2b2be6dac..deb8f5047c 100644 --- a/services/web/public/coffee/ide/editor/Document.coffee +++ b/services/web/public/coffee/ide/editor/Document.coffee @@ -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 diff --git a/services/web/public/coffee/ide/editor/EditorManager.coffee b/services/web/public/coffee/ide/editor/EditorManager.coffee index d190c06be9..fa9ad69498 100644 --- a/services/web/public/coffee/ide/editor/EditorManager.coffee +++ b/services/web/public/coffee/ide/editor/EditorManager.coffee @@ -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 diff --git a/services/web/public/coffee/ide/editor/ShareJsDoc.coffee b/services/web/public/coffee/ide/editor/ShareJsDoc.coffee index 3a1728c9c6..0894bbff7e 100644 --- a/services/web/public/coffee/ide/editor/ShareJsDoc.coffee +++ b/services/web/public/coffee/ide/editor/ShareJsDoc.coffee @@ -57,7 +57,7 @@ define [ @_handleError(error) if message?.meta?.type == "external" - @trigger "externalUpdate" + @trigger "externalUpdate", message catchUp: (updates) -> for update, i in updates diff --git a/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee b/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee index 3b5c4fc54e..e9c144b017 100644 --- a/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee @@ -227,8 +227,7 @@ describe 'Flushing documents :', -> url: url json: lines: @lines - headers: - "x-sl-update-source": @source + source: @source }) .should.equal true