mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: caches icon picker full icon's list (#8862)
This commit is contained in:
@@ -8,14 +8,34 @@ export default MultiSelectComponent.extend({
|
|||||||
pluginApiIdentifiers: ["icon-picker"],
|
pluginApiIdentifiers: ["icon-picker"],
|
||||||
classNames: ["icon-picker"],
|
classNames: ["icon-picker"],
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this._cachedIconsList = null;
|
||||||
|
},
|
||||||
|
|
||||||
content: computed("value.[]", function() {
|
content: computed("value.[]", function() {
|
||||||
return makeArray(this.value).map(this._processIcon);
|
return makeArray(this.value).map(this._processIcon);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
search(filter = "") {
|
search(filter = "") {
|
||||||
return ajax("/svg-sprite/picker-search", { data: { filter } }).then(icons =>
|
if (
|
||||||
icons.map(this._processIcon)
|
filter === "" &&
|
||||||
);
|
this._cachedIconsList &&
|
||||||
|
this._cachedIconsList.length
|
||||||
|
) {
|
||||||
|
return this._cachedIconsList;
|
||||||
|
} else {
|
||||||
|
return ajax("/svg-sprite/picker-search", {
|
||||||
|
data: { filter }
|
||||||
|
}).then(icons => {
|
||||||
|
icons = icons.map(this._processIcon);
|
||||||
|
if (filter === "") {
|
||||||
|
this._cachedIconsList = icons;
|
||||||
|
}
|
||||||
|
return icons;
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_processIcon(icon) {
|
_processIcon(icon) {
|
||||||
@@ -48,6 +68,8 @@ export default MultiSelectComponent.extend({
|
|||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
$("#svg-sprites .ajax-icon-holder").remove();
|
$("#svg-sprites .ajax-icon-holder").remove();
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this._cachedIconsList = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user