fix: sync code import not applying data after authentication
When importing an encrypted sync code, the flow was: 1. Click Apply → importSyncCode returns needsAuth 2. Auth prompt shown → user enters password → authentication succeeds 3. Green checkmark shown... but nobody re-runs the import The user had to manually click Apply a second time. Now the import automatically retries after successful authentication via a __ssPendingSyncImport callback. https://claude.ai/code/session_01SWSwDfMVij53bCTNSCLMwn
This commit is contained in:
+17
-4
@@ -93,15 +93,20 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
setSyncStatus('', 'neutral');
|
setSyncStatus('', 'neutral');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#btnApplySyncCode').addEventListener('click', async () => {
|
$('#btnApplySyncCode').addEventListener('click', applySyncCode);
|
||||||
|
|
||||||
|
async function applySyncCode() {
|
||||||
const code = $('#syncImportText').value.trim();
|
const code = $('#syncImportText').value.trim();
|
||||||
if (!code) return;
|
if (!code) return;
|
||||||
const force = $('#syncForce').checked;
|
const force = $('#syncForce').checked;
|
||||||
const result = await SilentSendSync.importSyncCode(code, { force });
|
const result = await SilentSendSync.importSyncCode(code, { force });
|
||||||
if (result.needsAuth) {
|
if (result.needsAuth) {
|
||||||
setSyncStatus('Authentication required to decrypt this sync code.', 'warn');
|
setSyncStatus('Authentication required — enter your encryption password, then the import will continue.', 'warn');
|
||||||
showSyncAuthPrompt();
|
showSyncAuthPrompt('decrypt');
|
||||||
|
// After auth succeeds, retry the import automatically
|
||||||
|
window.__ssPendingSyncImport = applySyncCode;
|
||||||
} else if (result.success) {
|
} else if (result.success) {
|
||||||
|
window.__ssPendingSyncImport = null;
|
||||||
setSyncStatus(`Imported successfully (data from ${result.importTime}).`, 'ok');
|
setSyncStatus(`Imported successfully (data from ${result.importTime}).`, 'ok');
|
||||||
$('#syncImportSection').style.display = 'none';
|
$('#syncImportSection').style.display = 'none';
|
||||||
$('#syncImportText').value = '';
|
$('#syncImportText').value = '';
|
||||||
@@ -109,6 +114,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
settings = await Storage.getSettings();
|
settings = await Storage.getSettings();
|
||||||
$('#browserSync').checked = settings.browserSync === true;
|
$('#browserSync').checked = settings.browserSync === true;
|
||||||
renderMappings();
|
renderMappings();
|
||||||
|
renderPasswords();
|
||||||
renderDomains();
|
renderDomains();
|
||||||
renderLog();
|
renderLog();
|
||||||
} else if (result.skipped) {
|
} else if (result.skipped) {
|
||||||
@@ -119,7 +125,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
} else {
|
} else {
|
||||||
setSyncStatus(`Failed: ${result.reason}`, 'error');
|
setSyncStatus(`Failed: ${result.reason}`, 'error');
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
$('#btnCancelSyncImport').addEventListener('click', () => {
|
$('#btnCancelSyncImport').addEventListener('click', () => {
|
||||||
$('#syncImportSection').style.display = 'none';
|
$('#syncImportSection').style.display = 'none';
|
||||||
@@ -1026,6 +1032,13 @@ async function initSyncEncryptionUI() {
|
|||||||
$('#syncAuthPassword').value = '';
|
$('#syncAuthPassword').value = '';
|
||||||
$('#syncAuthTOTPForPassword').value = '';
|
$('#syncAuthTOTPForPassword').value = '';
|
||||||
setSyncEncStatus(cached ? 'Re-verified with password.' : 'Authenticated. Sync data unlocked.', 'ok');
|
setSyncEncStatus(cached ? 'Re-verified with password.' : 'Authenticated. Sync data unlocked.', 'ok');
|
||||||
|
|
||||||
|
// If there's a pending sync import, retry it now that auth succeeded
|
||||||
|
if (window.__ssPendingSyncImport) {
|
||||||
|
const retry = window.__ssPendingSyncImport;
|
||||||
|
window.__ssPendingSyncImport = null;
|
||||||
|
await retry();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setSyncAuthStatus(result.reason, 'error');
|
setSyncAuthStatus(result.reason, 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user