mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix plugin cards not updating for some data changes
If Plugin.hasUserEdits or Plugin.isSearchResult changes state, the corresponding plugin card, if present, will be updated.
This commit is contained in:
@@ -330,6 +330,9 @@ loot-clear-metadata
|
||||
this._setTagsContent(cardContent.tags);
|
||||
this._setMessagesContent(cardContent.messages);
|
||||
|
||||
this.hasUserEdits = this.data.hasUserEdits;
|
||||
this.isSearchResult = this.data.isSearchResult;
|
||||
|
||||
/* Update the conflict filter toggle state. */
|
||||
this.$.showOnlyConflicts.checked = this.data.isConflictFilterChecked;
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
this.isMenuOpen = false;
|
||||
this._isEditorOpen = false;
|
||||
this.isConflictFilterChecked = false;
|
||||
this.isSearchResult = false;
|
||||
this._isSearchResult = false;
|
||||
}
|
||||
|
||||
static fromJson(key, value) {
|
||||
@@ -354,6 +354,7 @@
|
||||
this._userlist = userlist;
|
||||
|
||||
this._dispatchItemContentChangeEvent();
|
||||
this._dispatchCardContentChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,6 +394,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
get isSearchResult() {
|
||||
return this._isSearchResult;
|
||||
}
|
||||
|
||||
set isSearchResult(isSearchResult) {
|
||||
if (this._isSearchResult !== isSearchResult) {
|
||||
this._isSearchResult = isSearchResult;
|
||||
|
||||
this._dispatchCardContentChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
getCardContent(filters) {
|
||||
return new PluginCardContent(this, filters);
|
||||
}
|
||||
|
||||
@@ -885,6 +885,55 @@ describe('Plugin', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isSearchResult', () => {
|
||||
let handleEvent;
|
||||
|
||||
afterEach(() => {
|
||||
document.removeEventListener('loot-plugin-card-content-change', handleEvent);
|
||||
});
|
||||
|
||||
it('getting value should return false if it has not been set in the constructor', () => {
|
||||
const plugin = new loot.Plugin({ name: 'test' });
|
||||
|
||||
plugin.isSearchResult.should.be.false();
|
||||
});
|
||||
|
||||
it('setting value should store set value', () => {
|
||||
const plugin = new loot.Plugin({ name: 'test' });
|
||||
|
||||
plugin.isSearchResult = true;
|
||||
|
||||
plugin.isSearchResult.should.be.true();
|
||||
});
|
||||
|
||||
it('setting value to the current value should not fire an event', (done) => {
|
||||
const plugin = new loot.Plugin({ name: 'test' });
|
||||
|
||||
handleEvent = () => {
|
||||
done(new Error('Should not have fired an event'));
|
||||
};
|
||||
|
||||
document.addEventListener('loot-plugin-card-content-change', handleEvent);
|
||||
|
||||
plugin.isSearchResult = plugin.isSearchResult;
|
||||
|
||||
setTimeout(done, 100);
|
||||
});
|
||||
|
||||
it('setting value not equal to the current value should fire an event', (done) => {
|
||||
const plugin = new loot.Plugin({ name: 'test' });
|
||||
|
||||
handleEvent = (evt) => {
|
||||
evt.detail.pluginId.should.equal(plugin.id);
|
||||
done();
|
||||
};
|
||||
|
||||
document.addEventListener('loot-plugin-card-content-change', handleEvent);
|
||||
|
||||
plugin.isSearchResult = true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCardContent()', () => {
|
||||
let plugin;
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user