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

Stabilize preferences initialization #6719

Merged
merged 12 commits into from
Feb 26, 2014
Merged

Stabilize preferences initialization #6719

merged 12 commits into from
Feb 26, 2014

Conversation

busykai
Copy link
Contributor

@busykai busykai commented Jan 31, 2014

Instead of chaining the adding of the scopes at the caller, scopes are now added in the order the addScope was called. For each scopeOrder, a shadowScopeOrder is maintained which tracks the scope load status. If the scope was specified explicit "before" location and the "before" scope failed to load, it will be added to the first successfully loaded scope after "before". "default" scope is always loaded for the context and it's always resolved.

Deficient $.when is replaced with new Async.waitForAll (which would call always only when all promises are either resolved or rejected).

cc: @dangoor -- this is working, but not mergeable fix for #6660. I'll create task list to complete it later today or tomorrow. Please let me know what you think.

TODO:

  • load scopes if "before" scope has failed to load
  • do not require the caller to chain promises to add scopes in order
  • always create "user" scope, even if the one that has been requested has failed
  • warn user on corrupt brackets.json ("user" scope) on start-up and open it for editing
  • make sure preferences are loaded before any extension starts to load
  • comment/document the implementation
  • review test failures
  • refactor the tests to catch async (e.g. load failures)

Missing documentation, test failures. This is primarily for review.
Clean-up all the structures on remove: remove/add is used to setup the
tests.
@busykai
Copy link
Contributor Author

busykai commented Jan 31, 2014

@dangoor what about creating in-memory user scope when the system fails (due to parse or fs error)? Brackets should also warn that the user prefs cannot be parsed/loaded.

@marcelgerber
Copy link
Contributor

@busykai You got a JSHint Error -> Travis failure.

@busykai
Copy link
Contributor Author

busykai commented Feb 1, 2014

thanks, @SAplayer ! i'll fix it with the next set of changes.

"user" scope is treated differently than the rest of the scopes. if it
fails, then "user" scope is installed using memory storage.
additionally, when it fails due to ParsingError, the user is warned and
the configuration file is loaded so that it could be fixed.
…ions' into fix-6660

Seemingly working merge with current work by @dangoor in adobe#6715.

Conflicts:
	src/preferences/PreferencesBase.js
	src/preferences/PreferencesManager.js
@dangoor
Copy link
Contributor

dangoor commented Feb 19, 2014

@busykai I'm going to start reviewing this now. All that's left is the test change you referenced in your checklist?

@busykai
Copy link
Contributor Author

busykai commented Feb 20, 2014

@dangoor I'm working on merge with master which has #6715. PrefSystem does not get notifications from project scope (which means there's an error in contexts/binds somewhere). As soon as I'm done fixing it, it will be ready for review.

@dangoor
Copy link
Contributor

dangoor commented Feb 20, 2014

@busykai Good to know, thanks for the update.

@busykai
Copy link
Contributor Author

busykai commented Feb 21, 2014

@dangoor ready for review.

@dangoor
Copy link
Contributor

dangoor commented Feb 24, 2014

@busykai would you mind merging master into your branch? Sorry for the churn. I think the merge is easy (and did it myself), but I wouldn't want to mess it up!

Conflicts:
	src/preferences/PreferencesManager.js
@busykai
Copy link
Contributor Author

busykai commented Feb 25, 2014

@dangoor, done! Didn't realize that view status has landed. all tests pass.

@@ -65,6 +65,11 @@ define({
"ERROR_CREATING_FILE_TITLE" : "Error creating {0}",
"ERROR_CREATING_FILE" : "An error occurred when trying to create the {0} <span class='dialog-filename'>{1}</span>. {2}",

// Application preferences corrupt error strings
"ERROR_PREFS_CORRUPT_TITLE" : "Preferences file is corrupt",
"ERROR_PREFS_CORRUPT" : "{APP_NAME} preferences file is not a valid JSON and cannot be parsed. It will now be opened so that you could fix it. You will need to restart or reload {APP_NAME} for the changes to take effect.",
Copy link
Contributor

Choose a reason for hiding this comment

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

How about something like:

"ERROR_PREFS_CORRUPT_TITLE"         : "Error reading preferences",
"ERROR_PREFS_CORRUPT"               : "Your preferences file is not valid JSON. The file will be opened so that you can correct the format. You will need to restart {APP_NAME} for the changes to take effect.",

@dangoor
Copy link
Contributor

dangoor commented Feb 25, 2014

Review complete. The change appears to work well in my bit of testing just now.

I think just those handful of minor things to address and this will be set.

@dangoor
Copy link
Contributor

dangoor commented Feb 26, 2014

Looks good. Merging

@dangoor
Copy link
Contributor

dangoor commented Feb 26, 2014

Err, except I can't because of a conflict...

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

Successfully merging this pull request may close these issues.

3 participants