mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix "You have not sorted..." reappearing
The "You have not sorted..." message was reappearing after sorting your load order when no changes were necessary, then switching to another game then back again, because the cancelSort query was reinstating the message. A new discardUnappliedChanges query was added to ensure the change counter is zeroed, and that used where appropriate instead of cancelSort.
This commit is contained in:
@@ -180,6 +180,12 @@ namespace loot {
|
||||
callback->Success("");
|
||||
return true;
|
||||
}
|
||||
else if (request == "discardUnappliedChanges") {
|
||||
while (_lootState.hasUnappliedChanges())
|
||||
_lootState.decrementUnappliedChangeCounter();
|
||||
callback->Success("");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// May be a request with arguments.
|
||||
YAML::Node req;
|
||||
|
||||
@@ -119,9 +119,9 @@ function onSortPlugins() {
|
||||
existingPlugin.isEmpty = plugin.isEmpty;
|
||||
}
|
||||
});
|
||||
/* Send cancelSort query to notify that no unapplied sorting changes are
|
||||
present. Not doing so prevents LOOT's window from closing. */
|
||||
loot.query('cancelSort');
|
||||
/* Send discardUnappliedChanges query. Not doing so prevents LOOT's window
|
||||
from closing. */
|
||||
loot.query('discardUnappliedChanges');
|
||||
loot.Dialog.closeProgress();
|
||||
loot.Dialog.showNotification(loot.l10n.translate('Sorting made no changes to the load order.'));
|
||||
return;
|
||||
@@ -333,18 +333,8 @@ function handleUnappliedChangesClose(change) {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
/* Cancel any sorting and close any editors. Cheat by sending a
|
||||
cancelSort query for as many times as necessary. */
|
||||
const queries = [];
|
||||
let numQueries = 0;
|
||||
if (!document.getElementById('applySortButton').hidden) {
|
||||
numQueries += 1;
|
||||
}
|
||||
numQueries += document.body.getAttribute('data-editors');
|
||||
for (let i = 0; i < numQueries; ++i) {
|
||||
queries.push(loot.query('cancelSort'));
|
||||
}
|
||||
Promise.all(queries).then(() => {
|
||||
/* Discard any unapplied changes. */
|
||||
loot.query('discardUnappliedChanges').then(() => {
|
||||
window.close();
|
||||
}).catch(handlePromiseError);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user