mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 16:44:16 +08:00
Misc performance improvements for thread list
This commit is contained in:
parent
3ac2848174
commit
30885be8e4
2 changed files with 7 additions and 6 deletions
|
@ -93,7 +93,7 @@ class Scrollbar extends React.Component
|
||||||
|
|
||||||
position:'relative'
|
position:'relative'
|
||||||
height: handleHeight || 0
|
height: handleHeight || 0
|
||||||
top: handleTop || 0
|
transform: 'translate3d(0, ' + Math.floor(handleTop) + 'px, 0)'
|
||||||
|
|
||||||
_scrollbarWrapStyles: =>
|
_scrollbarWrapStyles: =>
|
||||||
position:'absolute'
|
position:'absolute'
|
||||||
|
|
|
@ -8,12 +8,13 @@ export class Registry {
|
||||||
|
|
||||||
constructor(name) {
|
constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this._registry = new Map();
|
this.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
register(extension, {priority = 0} = {}) {
|
register(extension, {priority = 0} = {}) {
|
||||||
this.validateExtension(extension, 'register');
|
this.validateExtension(extension, 'register');
|
||||||
this._registry.set(extension.name, {extension, priority});
|
this._registry.push({name: extension.name, extension, priority});
|
||||||
|
this._registry.sort((a, b) => a.priority < b.priority);
|
||||||
this.triggerDebounced();
|
this.triggerDebounced();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -25,14 +26,14 @@ export class Registry {
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions() {
|
extensions() {
|
||||||
return _.pluck(_.sortBy(Array.from(this._registry.values()), "priority"), "extension").reverse()
|
return this._registry.map(e => e.extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this._registry = new Map();
|
this._registry = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerDebounced = _.debounce(::this.trigger, 1);
|
triggerDebounced = _.debounce(() => this.trigger(), 1);
|
||||||
|
|
||||||
validateExtension(extension, method) {
|
validateExtension(extension, method) {
|
||||||
if (!extension || Array.isArray(extension) || !_.isObject(extension)) {
|
if (!extension || Array.isArray(extension) || !_.isObject(extension)) {
|
||||||
|
|
Loading…
Reference in a new issue