code cosmetics: simplify import::undo
This commit is contained in:
parent
3b433adb42
commit
fc7793453c
|
@ -194,15 +194,18 @@ function importFromString(jsonString) {
|
||||||
...stats.codeOnly.ids,
|
...stats.codeOnly.ids,
|
||||||
...stats.added.ids,
|
...stats.added.ids,
|
||||||
];
|
];
|
||||||
|
let resolve;
|
||||||
index = 0;
|
index = 0;
|
||||||
return new Promise(undoNextId)
|
return new Promise(resolve_ => {
|
||||||
.then(BG.refreshAllTabs)
|
resolve = resolve_;
|
||||||
|
undoNextId();
|
||||||
|
}).then(BG.refreshAllTabs)
|
||||||
.then(() => messageBox({
|
.then(() => messageBox({
|
||||||
title: t('importReportUndoneTitle'),
|
title: t('importReportUndoneTitle'),
|
||||||
contents: newIds.length + ' ' + t('importReportUndone'),
|
contents: newIds.length + ' ' + t('importReportUndone'),
|
||||||
buttons: [t('confirmOK')],
|
buttons: [t('confirmOK')],
|
||||||
}));
|
}));
|
||||||
function undoNextId(resolve) {
|
function undoNextId() {
|
||||||
if (index == newIds.length) {
|
if (index == newIds.length) {
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
|
@ -211,13 +214,10 @@ function importFromString(jsonString) {
|
||||||
deleteStyleSafe({id, notify: false}).then(id => {
|
deleteStyleSafe({id, notify: false}).then(id => {
|
||||||
const oldStyle = oldStylesById.get(id);
|
const oldStyle = oldStylesById.get(id);
|
||||||
if (oldStyle) {
|
if (oldStyle) {
|
||||||
saveStyleSafe(Object.assign(oldStyle, {
|
saveStyleSafe(Object.assign(oldStyle, SAVE_OPTIONS))
|
||||||
reason: 'import',
|
.then(undoNextId);
|
||||||
notify: false,
|
|
||||||
})).then(() =>
|
|
||||||
setTimeout(undoNextId, 0, resolve));
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(undoNextId, 0, resolve);
|
undoNextId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user