mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix counters not including plugins after sort
Modifying the existing plugins array doesn't fire the update event, so the counters weren't recalculated.
This commit is contained in:
@@ -291,8 +291,8 @@
|
||||
|
||||
setSortedPlugins(plugins) {
|
||||
this.oldLoadOrder = this.plugins;
|
||||
this.plugins = [];
|
||||
|
||||
const newPlugins = [];
|
||||
plugins.forEach((plugin) => {
|
||||
let existingPlugin = this.oldLoadOrder.find(item => item.name === plugin.name);
|
||||
if (existingPlugin) {
|
||||
@@ -300,8 +300,10 @@
|
||||
} else {
|
||||
existingPlugin = new Plugin(plugin);
|
||||
}
|
||||
this.plugins.push(existingPlugin);
|
||||
newPlugins.push(existingPlugin);
|
||||
});
|
||||
|
||||
this.plugins = newPlugins;
|
||||
}
|
||||
|
||||
applySort() {
|
||||
|
||||
@@ -458,11 +458,16 @@ describe('Game', () => {
|
||||
|
||||
describe('#setSortedPlugins', () => {
|
||||
let game;
|
||||
let handleEvent;
|
||||
|
||||
beforeEach(() => {
|
||||
game = new loot.Game({}, l10n);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.removeEventListener('loot-game-plugins-change', handleEvent);
|
||||
});
|
||||
|
||||
it('should append new plugins to the plugins array', () => {
|
||||
game.setSortedPlugins([{
|
||||
name: 'foo',
|
||||
@@ -520,6 +525,17 @@ describe('Game', () => {
|
||||
game.oldLoadOrder[0].name.should.equal('foo');
|
||||
game.oldLoadOrder[1].name.should.equal('bar');
|
||||
});
|
||||
|
||||
it('should dispatch an event', (done) => {
|
||||
handleEvent = () => {
|
||||
done();
|
||||
};
|
||||
document.addEventListener('loot-game-plugins-change', handleEvent);
|
||||
|
||||
game.setSortedPlugins([{
|
||||
name: 'foo',
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#applySort', () => {
|
||||
|
||||
Reference in New Issue
Block a user