Compare commits

..

10 Commits

10 changed files with 56 additions and 84 deletions

View File

@@ -103,7 +103,9 @@ function startRPC() {
}); });
rpc.login({ clientId }).catch(err => { rpc.login({ clientId }).catch(err => {
logger.error("Unable to connect to the RPC:", err); // Since 1.6.2, it no longer print the error. This is because if discord is not opened, it will send an error.
// logger.error("Unable to connect to the RPC:", err);
logger.info("Unable to connect to the Discord RPC. Discord is maybe not launched");
}); });
} }
@@ -132,7 +134,8 @@ async function stopRPC() {
await rpc.destroy(); await rpc.destroy();
} catch (err) { } catch (err) {
logger.error("Error while closing the RPC:", err); // Since 1.6.2, it no longer print the error. This is because if discord is not opened, it will send an error.
// logger.error("Error while closing the RPC:", err);
} }
} }
} }

19
main.js
View File

@@ -41,7 +41,10 @@ const { logger, logSessionStart, logSessionEnd, logDir } = require("./server/log
const { configFeatures } = require("./config"); const { configFeatures } = require("./config");
/** /**
* On start, enable or disable hardWareAcceleration * In-memory snapshot of application feature flags.
*
* Note: Changes to the config file are not automatically reflected.
* A restart could be required.
*/ */
if (!configFeatures.enableHardwareAcceleration){ if (!configFeatures.enableHardwareAcceleration){
app.disableHardwareAcceleration(); app.disableHardwareAcceleration();
@@ -50,15 +53,7 @@ if (!configFeatures.enableHardwareAcceleration){
logger.info("Enable Hardware Acceleration") logger.info("Enable Hardware Acceleration")
} }
/** if(configFeatures.devMode){
* In-memory snapshot of application feature flags.
*
* Note: Changes to the config file are not automatically reflected.
* A restart could be required.
*/
const config = require("./config");
if(config.devMode){
/** /**
* Start devTron extensions - @see https://github.com/electron/devtron * Start devTron extensions - @see https://github.com/electron/devtron
*/ */
@@ -117,7 +112,7 @@ app.whenReady().then(async () => {
createSplashWindow(); createSplashWindow();
if (!config.devMode && !checkNativeDependencies()) return; if (!configFeatures.devMode && !checkNativeDependencies()) return;
const { userYtDlp } = require("./server/helpers/path.helpers"); const { userYtDlp } = require("./server/helpers/path.helpers");
updateYtDlp(userYtDlp); updateYtDlp(userYtDlp);
@@ -143,7 +138,7 @@ app.whenReady().then(async () => {
getMainWindow().show(); getMainWindow().show();
if (configFeatures.systemTray) { if (configFeatures.systemTray) {
createSystemTray(getMainWindow(), config.devMode); createSystemTray(getMainWindow(), configFeatures.devMode);
} }
if (configFeatures.discordRPC) startRPC(); if (configFeatures.discordRPC) startRPC();

View File

@@ -1,7 +1,7 @@
{ {
"name": "freedom-loader", "name": "freedom-loader",
"productName": "Freedom Loader", "productName": "Freedom Loader",
"version": "1.6.2-preview", "version": "1.6.2",
"author": "MasterAcnolo <MasterAcnolo@users.noreply.github.com>", "author": "MasterAcnolo <MasterAcnolo@users.noreply.github.com>",
"description": "Free and open-source GUI for yt-dlp — download video and audio from hundreds of platforms", "description": "Free and open-source GUI for yt-dlp — download video and audio from hundreds of platforms",
"homepage": "https://masteracnolo.github.io/Freedom-Loader-Site/", "homepage": "https://masteracnolo.github.io/Freedom-Loader-Site/",

View File

@@ -56,9 +56,9 @@
<div class="setting-item" id="theme" style="margin-left: 32px;"> <div class="setting-item" id="theme" style="margin-left: 32px;">
<div class="setting-info"> <div class="setting-info">
<div style="display: flex; align-items: center; gap: 10px;"> <div style="display: flex; align-items: center; gap: 10px;">
<span class="setting-title">Thème</span> <span class="setting-title">Theme</span>
<select id="themeSelect" data-key="theme" aria-label="Choisir le thème"> <select id="themeSelect" data-key="theme" aria-label="Choose the theme">
</select> </select>
<button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn"> <button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn">
@@ -306,7 +306,6 @@
<!-- Scripts --> <!-- Scripts -->
<script src="script/toast.js"></script> <script src="script/toast.js"></script>
<script src="script/customConfiguration.js"></script>
<script src="script/clipboardPaste.js"></script> <script src="script/clipboardPaste.js"></script>
<script src="script/custompath.js"></script> <script src="script/custompath.js"></script>
<script src="script/settingsPanel.js"></script> <script src="script/settingsPanel.js"></script>

View File

@@ -7,7 +7,7 @@
* *
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async function versionLabel() { async function displayVersionLabel() {
/** /**
* Raw version string from the backend (e.g., "dev-1.6.2-preview" or "v1.6.2") * Raw version string from the backend (e.g., "dev-1.6.2-preview" or "v1.6.2")
* @type {string} * @type {string}
@@ -51,4 +51,4 @@ async function versionLabel() {
versionBadge.textContent = `${packageStateStr}${previewStr}v${baseVersion}`; versionBadge.textContent = `${packageStateStr}${previewStr}v${baseVersion}`;
} }
versionLabel(); displayVersionLabel();

View File

@@ -1,27 +0,0 @@
async function initPlatformRestrictions() {
const platform = await window.electronAPI.getProcessPlatform();
const themeSelect = document.getElementById("themeSelect");
const refreshBtn = document.getElementById("refresh-themes-btn");
/**
* Is the OS windows
* @type {boolean}
*/
const isWindows = platform === "win32";
console.log(isWindows);
// If it's windows, the button is not disabled.
themeSelect.disabled = !isWindows;
refreshBtn.disabled = !isWindows;
themeSelect.classList.toggle("disabled", !isWindows);
refreshBtn.classList.toggle("disabled", !isWindows);
if (!isWindows) {
themeSelect.title = "Themes are only available on Windows";
refreshBtn.title = "Themes are only available on Windows";
}
}

View File

@@ -121,7 +121,7 @@ async function initThemes() {
const defaultTheme = { const defaultTheme = {
id: "dark", id: "dark",
name: "Dark", name: "Dark",
subtitle: "Darkness is my ally", subtitle: "Because Why Not ?",
style: { style: {
background: { background: {
size: "cover", size: "cover",

View File

@@ -5,53 +5,55 @@
* This function is safe to call once DOM is ready. * This function is safe to call once DOM is ready.
* It silently aborts if the API or elements are missing. * It silently aborts if the API or elements are missing.
*/ */
function setupTopbarListeners() { export function initTopBar() {
const { topbarAPI } = window; const { topbarAPI } = window;
if (!topbarAPI) return; if (!topbarAPI) return;
const minBtn = document.getElementById("minimize-btn"); const minBtn = document.getElementById("minimize-btn");
const maxBtn = document.getElementById("maximize-btn");
const closeBtn = document.getElementById("close-btn");
const devtoolsBtn = document.getElementById("devtools-btn");
const logsBtn = document.getElementById("logs-btn");
const websiteBtn = document.getElementById("website-btn");
const wikiBtn = document.getElementById("wiki-btn");
const workshopBtn = document.getElementById("workshop-btn");
if (minBtn) minBtn.onclick = () => topbarAPI.minimize(); if (minBtn) minBtn.onclick = () => topbarAPI.minimize();
const maxBtn = document.getElementById("maximize-btn");
if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize(); if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize();
const closeBtn = document.getElementById("close-btn");
if (closeBtn) closeBtn.onclick = () => topbarAPI.close(); if (closeBtn) closeBtn.onclick = () => topbarAPI.close();
const devtoolsBtn = document.getElementById("devtools-btn");
if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools(); if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools();
const logsBtn = document.getElementById("logs-btn");
if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs(); if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs();
const websiteBtn = document.getElementById("website-btn");
if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite(); if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite();
const wikiBtn = document.getElementById("wiki-btn");
if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki(); if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki();
const workshopBtn = document.getElementById("workshop-btn");
if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop(); if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop();
} }
/** async function attachListeners(){
* Registers topbar event listeners after DOM is fully loaded. try{
*/ const featuresList = await window.electronAPI.getFeatures();
document.addEventListener("DOMContentLoaded", setupTopbarListeners);
if (!featuresList.customTopBar) {
/** const topbar = document.getElementById("topbar");
* Applies UI layout adjustments depending on feature flags const container = document.getElementById("container");
* provided by the Electron backend. const themeSwitcher = document.getElementById("theme-switcher");
*
* Specifically handles: if (topbar) topbar.style.display = "none";
* - hiding custom topbar if (container) container.style.marginTop = "0";
* - adjusting layout spacing if (themeSwitcher) themeSwitcher.style.top = "30px";
* - repositioning theme switcher }
*/
(async function applyFeatureLayout() { } catch (error) {
const features = await window.electronAPI.getFeatures(); console.error("Failed to load layout features for topbar:", error);
if (!features.customTopBar) {
const topbar = document.getElementById("topbar");
const container = document.getElementById("container");
const themeSwitcher = document.getElementById("theme-switcher");
if (topbar) topbar.style.display = "none";
if (container) container.style.marginTop = "0";
if (themeSwitcher) themeSwitcher.style.top = "30px";
} }
})();
}
initTopBar()
document.addEventListener("DOMContentLoaded", attachListeners)

View File

@@ -150,7 +150,7 @@ const binaryPaths = {
* - user themes are persisted in userData to survive updates * - user themes are persisted in userData to survive updates
*/ */
const userThemesPath = path.join(app.getPath("userData"), "themes"); const userThemesPath = path.join(app.getPath("userData"), "themes");
const defaultThemesSourcePath = path.join(resourcesPath, "theme"); const defaultThemesSourcePath = path.join("theme");
/** /**
* Initializes user theme directory and ensures default themes exist. * Initializes user theme directory and ensures default themes exist.

Binary file not shown.