-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π₯β¨ No more availableThemes (#8085)
no issue π¨ Switch themes API to use config.availableThemes - this gets rid of the only places where settings.availableThemes are used π₯ Get rid of settings.availableThemes - this is no longer used anywhere - also get rid of every related call to updateSettingsCache π₯ Replace config.availableThemes with theme cache - Creates a tailor-made in-memory cache for themes inside the theme module - Add methods for getting & setting items on the cache - Move all references to config.availableThemes to use the new cache - This can be abstracted later to support other kinds of caches? π¨ Start improving theme lib's API Still TODO: simplifying/clarifying: - what is the structure of the internal list - what is the difference between a package list, and a theme list? - what is the difference between reading a theme and loading it? - how do we update the theme list (add/remove) - how do we refresh the theme list? (hot reload?!) - how do we get from an internal list, to one that is sent as part of the API? - how are we going to handle theme storage: read/write, such that the path is configurable π¨ Use themeList consistently π¨ Update list after storage
- Loading branch information
Showing
19 changed files
with
277 additions
and
154 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
var themeLoader = require('./loader'); | ||
|
||
// @TODO: reduce the amount of things we expose to the outside world | ||
// Make this a nice clean sensible API we can all understand! | ||
module.exports = { | ||
init: themeLoader.init, | ||
load: themeLoader.load, | ||
loadAll: themeLoader.loadAllThemes, | ||
loadOne: themeLoader.loadOneTheme, | ||
list: require('./list'), | ||
validate: require('./validate') | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Store themes after loading them from the file system | ||
*/ | ||
var _ = require('lodash'), | ||
themeListCache = {}; | ||
|
||
module.exports = { | ||
get: function get(key) { | ||
return themeListCache[key]; | ||
}, | ||
|
||
getAll: function getAll() { | ||
return themeListCache; | ||
}, | ||
|
||
set: function set(key, theme) { | ||
themeListCache[key] = _.cloneDeep(theme); | ||
return themeListCache[key]; | ||
}, | ||
|
||
del: function del(key) { | ||
delete themeListCache[key]; | ||
}, | ||
|
||
init: function init(themes) { | ||
var self = this; | ||
// First, reset the cache | ||
themeListCache = {}; | ||
// For each theme, call set. Allows us to do processing on set later. | ||
_.each(themes, function (theme, key) { | ||
self.set(key, theme); | ||
}); | ||
|
||
return themeListCache; | ||
} | ||
}; |
Oops, something went wrong.