Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/ipc/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { ipcMain, shell, BrowserWindow } = require('electron');
const { app, ipcMain, shell, BrowserWindow } = require('electron');
const { randomUUID } = require('crypto');
const { getAppConfig, saveUserConfig, resetAppConfig } = require('../lib/config');
const { CONFIG_FILE } = require('../lib/paths');
Expand All @@ -15,11 +15,17 @@ const fs = require('fs');
function registerConfigHandlers(getVideodbService) {
ipcMain.handle('get-settings', () => {
const config = getAppConfig();
return { ...config, isConnected: !!config.accessToken };
const loginSettings = app.getLoginItemSettings();
return { ...config, isConnected: !!config.accessToken, openAtLogin: loginSettings.openAtLogin };
});

ipcMain.handle('save-settings', (event, data) => {
try {
// Apply login item setting via Electron API (not persisted in config file)
if (data.openAtLogin !== undefined) {
app.setLoginItemSettings({ openAtLogin: data.openAtLogin });
delete data.openAtLogin; // Don't persist in config — Electron manages this
}
saveUserConfig(data);
// Broadcast theme change to all other windows
if (data.theme) {
Expand Down
44 changes: 44 additions & 0 deletions src/renderer/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,43 @@
text-align: right;
}

/* Toggle switch */
.switch {
position: relative;
display: inline-block;
width: 36px;
height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
position: absolute;
cursor: pointer;
top: 0; left: 0; right: 0; bottom: 0;
background: var(--bg-primary);
border: 1px solid var(--border-subtle);
border-radius: 20px;
transition: background 0.2s;
}
.switch-slider::before {
content: "";
position: absolute;
height: 14px;
width: 14px;
left: 2px;
bottom: 2px;
background: var(--text-secondary);
border-radius: 50%;
transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-slider {
background: #EC5B16;
border-color: #EC5B16;
}
.switch input:checked + .switch-slider::before {
transform: translateX(16px);
background: #fff;
}

/* Theme toggle */
.theme-toggle {
display: flex;
Expand Down Expand Up @@ -1353,6 +1390,13 @@
</button>
</div>
</div>
<div class="settings-row">
<span class="settings-label">Launch on startup</span>
<label class="switch" id="openAtLoginSwitch">
<input type="checkbox" id="openAtLoginCheckbox">
<span class="switch-slider"></span>
</label>
</div>
<div class="settings-row">
<span class="settings-label">Shortcut</span>
<span class="settings-value">&#8984;&#8679;R</span>
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,9 +1029,20 @@ async function initSettings() {
document.querySelectorAll('.theme-toggle-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.theme === currentTheme);
});
// Sync launch-on-startup toggle
const openAtLoginCheckbox = document.getElementById('openAtLoginCheckbox');
if (openAtLoginCheckbox) {
openAtLoginCheckbox.checked = !!config.openAtLogin;
}
popover.classList.add('visible');
});

// Launch on startup toggle
const openAtLoginCheckbox = document.getElementById('openAtLoginCheckbox');
openAtLoginCheckbox?.addEventListener('change', () => {
window.configAPI.saveConfig({ openAtLogin: openAtLoginCheckbox.checked });
});

// Close on outside click (mousedown works in drag regions too)
document.addEventListener('mousedown', (e) => {
if (!e.target.closest('.settings-popover-wrap')) {
Expand Down