const UIManager = require('./utils/renderer/UIManager'); // Initialize the application when DOM is loaded document.addEventListener('DOMContentLoaded', () => { console.log('Movie Mapper application initialized'); // Create and initialize the UI manager const uiManager = new UIManager(); // Expose to window for debugging and external access window.uiManager = uiManager; // Debug function to log problematic file info window.debugProblematicFile = async (filePath) => { await uiManager.debugProblematicFile(filePath); }; // Test TVDB API connectivity window.testTVDBAPI = async () => { await uiManager.searchManager.testTVDBAPI(); }; // Open video preview window.openVideoPreview = async (filePath) => { await uiManager.modalManager.openVideoPreview(filePath); }; // Open directory window.openDirectory = async (directory) => { await uiManager.openDirectory(directory); }; // Make file editable window.makeEditable = (element) => { uiManager.makeEditable(element); }; console.log('UIManager initialized and exposed to window'); }); // IPC handlers for file operations (these are called from main process) // File rename handler const { ipcRenderer } = require('electron'); // Handle file rename requests ipcRenderer.invoke('rename-file', async (event, { oldPath, newName }) => { const path = require('path'); try { const oldDir = path.dirname(oldPath); const newPath = path.join(oldDir, newName); const fs = require('fs'); if (fs.existsSync(oldPath) && oldPath !== newPath) { fs.renameSync(oldPath, newPath); return { success: true, message: 'File renamed successfully' }; } else { return { success: false, error: 'File not found or paths are the same' }; } } catch (error) { return { success: false, error: error.message }; } }); console.log('Movie Mapper renderer loaded');