fix(journals): harden privacy toggle and add effect diagnostics
- Ensured content is decrypted before allowing conversion to plain text. - Added detailed diagnostic logging to reactive effects to debug loop issues. - Integrated background sync skip logic to preserve decrypted state.
This commit is contained in:
@@ -200,16 +200,27 @@ p-2 md:p-3 rounded-lg shadow-md
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={journal?.cfg_json?.hide_btn_private || (entry.private && !$ae_loc.edit_mode)}
|
||||
onclick={() => {
|
||||
onclick={async () => {
|
||||
if (!entry.private && entry.content) {
|
||||
if (confirm('Encrypt and resave this entry?')) {
|
||||
tmp_entry_obj.private = true;
|
||||
onSave();
|
||||
}
|
||||
} else if (entry.private && entry.content_encrypted) {
|
||||
if (confirm('Decrypt and resave unencrypted?')) {
|
||||
tmp_entry_obj.private = false;
|
||||
onSave();
|
||||
// CRITICAL: Ensure we have the decrypted content before we turn OFF privacy
|
||||
if (!tmp_entry_obj.content) {
|
||||
console.log('Header: Content not decrypted. Attempting decryption before toggle.');
|
||||
await onDecrypt();
|
||||
}
|
||||
|
||||
// Check again after attempted decryption
|
||||
if (tmp_entry_obj.content) {
|
||||
if (confirm('Decrypt and resave as plain text?')) {
|
||||
tmp_entry_obj.private = false;
|
||||
onSave();
|
||||
}
|
||||
} else {
|
||||
alert('Cannot convert to plain text: Entry is not decrypted. Please enter passcode first.');
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user