Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Live Preview MultiBrowser improvements (#10206, #10239) #10285

Merged
merged 1 commit into from
Jan 15, 2015

Conversation

busykai
Copy link
Contributor

@busykai busykai commented Dec 27, 2014

Fix #10206 (point 1):

PreferencesManager.on("change") was executing before AppInit.appReady().
This was causing various inconsistencies, including setting up the UI before
LiveDevelopment is actually initialized. Handling of pref change is now moved
to AppInit.appReady and the implementation is set only after the modules are
actually initialized.

Fix #10239:

Toggle menu item to enable/disable multi-browser live preview. Under File -> Enable Experimental Live Preview. Multiple fixes to implementation life-cycle to support correct state transitions on switch.

Minor nits included: pref definition improved, suite name made shorter, spare lines removed, documentation improvements.

CC: @peterflynn, @sebaslv, @redmunds

@@ -75,6 +75,10 @@ define(function main(require, exports, module) {

// current selected implementation (LiveDevelopment | LiveDevMultiBrowser)
var LiveDevImpl;

// "livedev.multibrowser" preference
var PREF_MULTIBROWSER = "livedev.multibrowser";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually should be PrefixedPreferencesSystem, I think.

@busykai busykai changed the title As per #10206: fix/improve LiveDevelopment init. [NOT READY] As per #10206: fix/improve LiveDevelopment init. Jan 9, 2015
@busykai busykai changed the title [NOT READY] As per #10206: fix/improve LiveDevelopment init. Live Preview MultiBrowser improvements (#10206, #10239) Jan 9, 2015
@busykai
Copy link
Contributor Author

busykai commented Jan 9, 2015

@redmunds, this is ready for a review.

@redmunds redmunds self-assigned this Jan 10, 2015
@redmunds
Copy link
Contributor

@busykai I found a weird case when testing this. Let me know if I should file this:

  1. Start Bracket s on a system with a local server setup and running
  2. Switch to a site with files on the local server
  3. I originally hit this by setting base url to be http://localhost/, but this is not required
  4. Switch to LiveDev MultiBrowser
  5. Start Live Dev

Results
Live Dev never completely connects. It stays in Connecting state.

I don't think it's related to this change. Let me know.

@busykai
Copy link
Contributor Author

busykai commented Jan 12, 2015

@redmunds, thanks for the use case! we will take a look.

CC @sebaslv

@sebaslv
Copy link
Contributor

sebaslv commented Jan 14, 2015

@redmunds, I'm trying to reproduce this case but still couldn't do it. This is what I'm doing:

  1. Start a local server which serves let say index.html file
  2. Start Brackets
  3. Open the folder that contains the index.html being served
  4. Open http://localhost/index.html in a browser
  5. File -> Enable Experimental Live Preview
  6. Start Live Dev

By following these steps I got LiveDev working. Please, let me know if those are representative of the steps you have described or if I misunderstood something. Thanks.

@redmunds
Copy link
Contributor

@sebaslv I did not open in browser first (step 4), so not sure if that's making a difference.

FYI, I'm seeing this on Win7 Firefox (latest) with WampServer 2.2 .

@sebaslv
Copy link
Contributor

sebaslv commented Jan 14, 2015

@redmunds, Thanks for the info. I was able to reproduce it now by configuring local server, the step I missed before I think :).

It seems that it never connects beacuse the page is not instrumented so the connect message never comes back from the browser after launching it. It looks like in this scenario, LiveDevMultiBrowser is getting an instance of UserServer since it has been registered by LiveDevelopment and both implementations share LiveDevServerManager.

Currently we're not managing that error. I'll create a fix for that independently of this case since it's pending. The thing is that it would close the connection which is something different to what the current implementation does in this scenario. I see that it launches the page and moves the icon to a connected status but keep live editing disabled. I could figure out how to identify the case and handle that in this particular way but not sure if that is the right UX we would like for this.

What do you guys suggest?

@redmunds
Copy link
Contributor

@sebaslv I agree that it should be a separate issue and not hold up this PR. I'll open new issue.

Seems like doing a better job of cleaning up when changing implementations should fix that.

@redmunds
Copy link
Contributor

@sebaslv I filed issue #10374 . I'm not sure I understand all of the subtle points, so feel free to update it.

@sebaslv
Copy link
Contributor

sebaslv commented Jan 14, 2015

Sounds good. I'll create a PR for that issue. Thanks.

@@ -230,9 +230,9 @@ define(function (require, exports, module) {
});
}

function toggleErrorNotification(bool) {
function togglePref(key, bool) {
var val,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes to DebugCommands/main.js are not necessary. I only refactored this code from toggleErrorNotification() into togglePref() to reduce duplication with new function, but it was moved to LiveDevelopment/main.js so there's no need for any changes here.

@redmunds
Copy link
Contributor

@busykai Done with review. This looks good. Just need to backout changes to DebugCommands/main.js and squash commits.

PreferencesManager.on("change") was executing before AppInit.appReady().
This was causing various inconsistencies, including setting up the UI before
LiveDevelopment is actually initialized. Handling of pref change is now moved
to AppInit.appReady and the implementation is set only after the modules are
actually initialized.

Fix #10239: toggle menu to switch livedev impls.
    - Ensure correct status changes when switching implementations.
    - Disable 'Project Settings' when multi-browser is on.

Also:
    - Minor improvements to how the pref is defined.
    - Close LiveDevelopment explicitly after each test.
    - Minor refactor/doc changes in LiveDevelopment/main.js
    - Minor stylistic and documentation changes.
@busykai busykai force-pushed the kai/fix-10206-ld-mb-unittests-part1 branch from 95cde63 to eef9c68 Compare January 15, 2015 06:08
@busykai
Copy link
Contributor Author

busykai commented Jan 15, 2015

@redmunds, done!

@redmunds
Copy link
Contributor

Merging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants