mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-25 15:22:24 +01:00
Squash Odysseus development history
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
// Keyboard Shortcuts — dynamic keybinds
|
||||
// ============================================
|
||||
|
||||
import { IS_MAC, isAltGrEvent } from './platform.js';
|
||||
import { getSettings } from './appConfig.js';
|
||||
|
||||
const _defaultKeybinds = {
|
||||
search: 'ctrl+k', toggle_sidebar: 'ctrl+alt+b', new_session: 'ctrl+alt+n',
|
||||
fav_session: 'ctrl+alt+f', delete_session: 'ctrl+alt+d',
|
||||
@@ -10,11 +13,14 @@ const _defaultKeybinds = {
|
||||
// Open-tool shortcuts (Calendar bound by default; rest unbound).
|
||||
open_calendar: 'ctrl+alt+c', open_compare: '', open_cookbook: '',
|
||||
open_research: '', open_gallery: '', open_library: '', open_memory: '',
|
||||
open_notes: '', open_tasks: '', open_theme: '',
|
||||
open_skills: '', open_notes: '', open_tasks: '', open_theme: '',
|
||||
};
|
||||
|
||||
function _matchesCombo(e, combo) {
|
||||
if (!combo) return false;
|
||||
export function _matchesCombo(e, combo, isMac = IS_MAC) {
|
||||
if (typeof combo !== 'string' || !combo) return false;
|
||||
// Drop AltGr keystrokes so typing characters on non-US layouts can't fire a
|
||||
// Ctrl+Alt shortcut — e.g. the destructive delete_session. See platform.js.
|
||||
if (isAltGrEvent(e, isMac)) return false;
|
||||
const parts = combo.split('+');
|
||||
const needCtrl = parts.includes('ctrl');
|
||||
const needAlt = parts.includes('alt');
|
||||
@@ -51,9 +57,16 @@ export function initKeyboardShortcuts(modules) {
|
||||
window._odysseusKeybinds = { ..._defaultKeybinds };
|
||||
|
||||
// Load saved keybinds
|
||||
fetch('/api/auth/settings', { credentials: 'same-origin' })
|
||||
.then(r => r.json())
|
||||
.then(s => { if (s.keybinds) window._odysseusKeybinds = { ..._defaultKeybinds, ...s.keybinds }; })
|
||||
getSettings()
|
||||
.then(s => {
|
||||
if (!s.keybinds) return;
|
||||
window._odysseusKeybinds = { ..._defaultKeybinds, ...s.keybinds };
|
||||
// Ctrl+B belongs to browser bookmarks. Migrate the former default when
|
||||
// encountered in saved settings instead of continuing to intercept it.
|
||||
if (window._odysseusKeybinds.toggle_sidebar === 'ctrl+b') {
|
||||
window._odysseusKeybinds.toggle_sidebar = _defaultKeybinds.toggle_sidebar;
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
// ── Esc cancels select mode (capture phase, before modal-close) ──
|
||||
@@ -148,15 +161,8 @@ export function initKeyboardShortcuts(modules) {
|
||||
}
|
||||
if (_matchesCombo(e, kb.toggle_sidebar)) {
|
||||
e.preventDefault();
|
||||
var sb = document.getElementById('sidebar');
|
||||
var ir = document.getElementById('icon-rail');
|
||||
if (sb && !sb.classList.contains('hidden')) {
|
||||
sb.classList.add('hidden');
|
||||
} else {
|
||||
if (ir) ir.classList.remove('rail-hidden');
|
||||
if (sb) sb.classList.remove('hidden');
|
||||
}
|
||||
if (typeof syncRailSide === 'function') syncRailSide();
|
||||
const toggle = el('hamburger-btn');
|
||||
if (toggle) toggle.click();
|
||||
return;
|
||||
}
|
||||
if (_matchesCombo(e, kb.tts)) {
|
||||
@@ -265,6 +271,7 @@ export function initKeyboardShortcuts(modules) {
|
||||
open_gallery: 'tool-gallery-btn',
|
||||
open_library: 'tool-library-btn',
|
||||
open_memory: 'tool-memory-btn',
|
||||
open_skills: 'tool-skills-btn',
|
||||
open_notes: 'tool-notes-btn',
|
||||
open_tasks: 'tool-tasks-btn',
|
||||
open_theme: 'tool-theme-btn',
|
||||
|
||||
Reference in New Issue
Block a user