fix: persist and sync LuckMail settings before runs

This commit is contained in:
zhangkun
2026-04-28 13:12:39 +08:00
parent 96e6fa9242
commit b678c32b55
4 changed files with 140 additions and 15 deletions
+11 -4
View File
@@ -1407,6 +1407,12 @@ async function settlePendingSettingsBeforeImport() {
await waitForSettingsSaveIdle();
}
async function persistCurrentSettingsForAction() {
clearTimeout(settingsAutoSaveTimer);
await waitForSettingsSaveIdle();
await saveSettings({ silent: true, force: true });
}
function downloadTextFile(content, fileName, mimeType = 'application/json;charset=utf-8') {
const blob = new Blob([content], { type: mimeType });
const objectUrl = URL.createObjectURL(blob);
@@ -2559,10 +2565,10 @@ function scheduleSettingsAutoSave() {
}
async function saveSettings(options = {}) {
const { silent = false } = options;
const { silent = false, force = false } = options;
clearTimeout(settingsAutoSaveTimer);
if (!settingsDirty && !settingsSaveInFlight && silent) {
if (!force && !settingsDirty && !settingsSaveInFlight && silent) {
return;
}
@@ -5005,6 +5011,7 @@ stepsList?.addEventListener('click', async (event) => {
if (!(await maybeTakeoverAutoRun(`执行步骤 ${step}`))) {
return;
}
await persistCurrentSettingsForAction();
if (step === 3) {
if (inputPassword.value !== (latestState?.customPassword || '')) {
await chrome.runtime.sendMessage({
@@ -5236,8 +5243,8 @@ async function startAutoRunFromCurrentSettings() {
console.warn('Failed to refresh contribution content hint before auto run:', error);
}
if (typeof settingsDirty !== 'undefined' && settingsDirty && typeof saveSettings === 'function') {
await saveSettings({ silent: true });
if (typeof persistCurrentSettingsForAction === 'function') {
await persistCurrentSettingsForAction();
}
const customEmailPoolEnabled = typeof usesCustomEmailPoolGenerator === 'function'