MovieMapper/utils/renderer/AppState.js
Jarian Cottingham d0c70ca3e2 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

143 lines
2.9 KiB
JavaScript

const path = require('path');
/**
* AppState - Manages application state
*/
class AppState {
constructor() {
this.currentDirectory = null;
this.currentFiles = [];
this.currentShow = null;
this.currentSeasons = [];
this.currentEpisodes = [];
this.selectedSeasonEpisodeCount = 0;
this.isUpdatingEpisodeNumbers = false;
}
/**
* Set the current directory
* @param {string} directory - Directory path
*/
setCurrentDirectory(directory) {
this.currentDirectory = directory;
}
/**
* Get the current directory
* @returns {string|null} Current directory path
*/
getCurrentDirectory() {
return this.currentDirectory;
}
/**
* Set current files
* @param {Array} files - Array of file objects
*/
setCurrentFiles(files) {
this.currentFiles = files;
}
/**
* Get current files
* @returns {Array} Array of file objects
*/
getCurrentFiles() {
return this.currentFiles;
}
/**
* Set current show
* @param {Object} show - Show object
*/
setCurrentShow(show) {
this.currentShow = show;
}
/**
* Get current show
* @returns {Object|null} Current show object
*/
getCurrentShow() {
return this.currentShow;
}
/**
* Set current seasons
* @param {Array} seasons - Array of season objects
*/
setCurrentSeasons(seasons) {
this.currentSeasons = seasons;
}
/**
* Get current seasons
* @returns {Array} Array of season objects
*/
getCurrentSeasons() {
return this.currentSeasons;
}
/**
* Set current episodes
* @param {Array} episodes - Array of episode objects
*/
setCurrentEpisodes(episodes) {
this.currentEpisodes = episodes;
}
/**
* Get current episodes
* @returns {Array} Array of episode objects
*/
getCurrentEpisodes() {
return this.currentEpisodes;
}
/**
* Set selected season episode count
* @param {number} count - Episode count
*/
setSelectedSeasonEpisodeCount(count) {
this.selectedSeasonEpisodeCount = count;
}
/**
* Get selected season episode count
* @returns {number} Episode count
*/
getSelectedSeasonEpisodeCount() {
return this.selectedSeasonEpisodeCount;
}
/**
* Check if episode numbers are currently updating
* @returns {boolean} True if updating
*/
isUpdatingEpisodeNumbers() {
return this.isUpdatingEpisodeNumbers;
}
/**
* Set episode numbers updating flag
* @param {boolean} updating - Updating state
*/
setUpdatingEpisodeNumbers(updating) {
this.isUpdatingEpisodeNumbers = updating;
}
/**
* Reset state to initial values
*/
reset() {
this.currentDirectory = null;
this.currentFiles = [];
this.currentShow = null;
this.currentSeasons = [];
this.currentEpisodes = [];
this.selectedSeasonEpisodeCount = 0;
this.isUpdatingEpisodeNumbers = false;
}
}
module.exports = AppState;