MovieMapper/renderer.js
Jarian Cottingham be887c3855 Refactor renderer.js into modular class-based structure
- Split large renderer.js file into 8 separate class files:
  - AppState.js: Manages application state
  - FileListManager.js: Handles file list display and manipulation
  - TagManager.js: Manages file tagging functionality
  - EpisodeManager.js: Handles episode number editing and highlighting
  - SearchManager.js: Manages TVDB search and show selection
  - FileManager.js: Handles file operations
  - ModalManager.js: Manages video preview modal
  - ProgressManager.js: Manages progress display
  - UIManager.js: Main coordinator for UI functionality
- Follows SOLID principles and single responsibility
- Improves code maintainability and testability
- All syntax verified with node --check
2026-02-25 02:32:08 -06:00

64 lines
1.9 KiB
JavaScript

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');