mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Only set metadata editor data when needed.
Provides a big improvement to card list scrolling performance. For #330.
This commit is contained in:
@@ -196,11 +196,14 @@ loot-clear-metadata
|
||||
},
|
||||
|
||||
dataChanged: function(oldValue, newValue) {
|
||||
/* Share the data with the editor. */
|
||||
this.shadowRoot.getElementById('editor').data = this.data;
|
||||
if (newValue != undefined) {
|
||||
if (newValue.isEditorOpen) {
|
||||
/* Share the data with the editor. */
|
||||
this.shadowRoot.getElementById('editor').data = newValue;
|
||||
}
|
||||
|
||||
/* Set the card flip state. */
|
||||
if (this.classList.contains('flip') != this.data.isEditorOpen) {
|
||||
if (this.classList.contains('flip') != newValue.isEditorOpen) {
|
||||
/* Temporarily speed up the flip effect, as otherwise fast
|
||||
scrolling lets the user see the end of it. */
|
||||
this.classList.add('fastflip');
|
||||
@@ -213,7 +216,7 @@ loot-clear-metadata
|
||||
this.onMessagesChange();
|
||||
|
||||
/* Also set highlight if the conflict filter is active. */
|
||||
this.classList.toggle('highlight', this.data.isConflictFilterChecked);
|
||||
this.classList.toggle('highlight', newValue.isConflictFilterChecked);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -277,6 +280,11 @@ loot-clear-metadata
|
||||
onShowEditor: function(evt) {
|
||||
var card = evt.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentNode.host;
|
||||
|
||||
/* If the editor hasn't already been opened, its data is not yet set, so do that now. */
|
||||
if (!card.data.isEditorOpen && !card.data.editor) {
|
||||
card.shadowRoot.getElementById('editor').data = card.data;
|
||||
}
|
||||
|
||||
card.data.isEditorOpen = true;
|
||||
|
||||
/* Fire an open event, so that the UI can enter edit mode. */
|
||||
|
||||
@@ -256,9 +256,8 @@ loot-editor-close
|
||||
},
|
||||
|
||||
dataChanged: function(oldValue, newValue) {
|
||||
/* Record the current editor data. This is only strictly necessary
|
||||
if the editor is currently open, but editor state isn't yet recorded. */
|
||||
if (oldValue) {
|
||||
/* Record the current editor data if the editor is open. */
|
||||
if (oldValue && this.data.isEditorOpen) {
|
||||
oldValue.editor = this.readFromEditor(oldValue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user