This repository was archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Fix shapes update #7424
Merged
Merged
Fix shapes update #7424
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a62e2b1
fix outstanding code review issues
oslego 52c1ca0
Fixes #7418 and #7421 - attempts to recover or teardown editor when e…
oslego a17a802
add a space to please the linter
oslego 89adb73
fix typos
oslego 700609d
remove duplicate unit test
oslego a301e8c
revert to using only T key as a trigger; Ctrl+T triggers a new tab on…
oslego 5d6cfe9
fix typo; undocument unused param
oslego File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,6 @@ define(function (require, exports, module) { | |
| } | ||
|
|
||
| /** | ||
| * @private | ||
| * Inject remote live editor driver and any specified editor providers. | ||
| * The remote live editor driver mirrors most of the local live editor driver API | ||
| * to provide an interface to the in-browser live editor. | ||
|
|
@@ -104,16 +103,16 @@ define(function (require, exports, module) { | |
| } | ||
|
|
||
| /** | ||
| * @private | ||
| * Send instructions to remove the live editor from the page in LivePreview. | ||
| * @return {$.Promise} | ||
| */ | ||
| function remove() { | ||
| if (_hasEditor === false) { | ||
| var deferred = $.Deferred(); | ||
| return deferred.reject(); | ||
| return deferred.reject().promise(); | ||
| } | ||
|
|
||
| _cache.model = undefined; // do not move in _reset(), otherwise the _reconnect() scenario misses the cache and fails | ||
| _reset(); | ||
| var expr = _namespace + ".remove()"; | ||
| return _call(expr); | ||
|
|
@@ -138,6 +137,10 @@ define(function (require, exports, module) { | |
| hasChanged = false, | ||
| key; | ||
|
|
||
| if (!data) { | ||
| remove(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oslego We should also return |
||
|
|
||
| // sync the local model snapshot with the remote model | ||
| _.forEach(data, function (value, key) { | ||
| if (!_model[key] || !_.isEqual(_model[key], value)) { | ||
|
|
@@ -155,18 +158,24 @@ define(function (require, exports, module) { | |
| /** | ||
| * @private | ||
| * Handle failed promises for eval() calls to the inspected page. | ||
| * Promises can fail if the user manually refreshes the page or navigates | ||
| * Promises fail if the user manually refreshes the page or navigates | ||
| * because the injected editor files will be lost. | ||
| * If this is the case, attempt to reconnect. | ||
| * | ||
| * @param {$.Promise=} result promise result | ||
| * Promises also fail because of errors thrown in the remote page. | ||
| * If this is the case, remove the editor. | ||
| */ | ||
| function _whenRemoteCallFailed(result) { | ||
| if (result) { | ||
| return _reconnect(); | ||
| } else { | ||
| _cache.model = undefined; | ||
| return remove(); | ||
| } | ||
| function _whenRemoteCallFailed() { | ||
| // check if the remote editor namespace is still defined on the page | ||
| _call(_namespace) | ||
| .then(function (response) { | ||
| if (response.type === "undefined") { | ||
| _reconnect(); | ||
| } else { | ||
| remove(); | ||
| } | ||
| }) | ||
| .fail(remove); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to return
return deferred.reject().promise()on line 73 inside_call()function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already returns
.reject()on line 73There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I updated it to
reject().promise()after I realized that I forgot to append the promise(). So it should have .promise().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And actually this is from @TomMalbran in this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 73 it returns
.reject()so it may be caught by_whenRemoteCallFailed()downstream.In that scenario (Inspector not connected), it will attempt reconnect a few times, then finally give up and remove the editor. Returning
.reject().promise()instead won't bypass this workflow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this line it is just a minor nit, so that the returned objects are always the same and correspond to the JSDocs.
The idea of returning a Promise is so that the function that uses it can't call resolve or reject over the deferred object. But since you are already returning a rejected deferred, the state can't be changed so returning a promise won't change that. You can still use then, done, fail, an all those methods on a promise.