mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-09 23:18:50 -04:00
Merge verified Odysseus fixes
This commit is contained in:
+14
-1
@@ -3,22 +3,35 @@
|
||||
|
||||
import Storage from './storage.js';
|
||||
|
||||
function markComposerUserEdited() {
|
||||
const msgInput = document.getElementById('message');
|
||||
if (!msgInput || msgInput.dataset.startupPreserveBound === '1') return;
|
||||
msgInput.dataset.startupPreserveBound = '1';
|
||||
msgInput.addEventListener('input', () => {
|
||||
window.__odysseusComposerUserEdited = !!msgInput.value;
|
||||
});
|
||||
}
|
||||
|
||||
function clearFreshComposerRestore() {
|
||||
const msgInput = document.getElementById('message');
|
||||
if (!msgInput) return;
|
||||
markComposerUserEdited();
|
||||
const hash = window.location.hash || '';
|
||||
const isEntityHash = /^#(?:document|note|image|email|event|task|skill|research)-/.test(hash)
|
||||
|| /^#open=notes¬e=/.test(hash);
|
||||
const hasSessionTarget = !!((hash && !isEntityHash) || Storage.get('lastSessionId'));
|
||||
const hasSessionTarget = !!(hash && !isEntityHash);
|
||||
if (hasSessionTarget) return;
|
||||
if (window.__odysseusComposerUserEdited || document.activeElement === msgInput) return;
|
||||
if (msgInput.value) {
|
||||
msgInput.value = '';
|
||||
msgInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
}
|
||||
|
||||
markComposerUserEdited();
|
||||
clearFreshComposerRestore();
|
||||
window.addEventListener('pageshow', clearFreshComposerRestore);
|
||||
document.addEventListener('DOMContentLoaded', markComposerUserEdited, { once: true });
|
||||
|
||||
// SECURITY: defense-in-depth state wipe on user switch. If the authenticated
|
||||
// user is different from the one whose state is cached in this browser,
|
||||
|
||||
Reference in New Issue
Block a user