Skip to content

Commit d192bed

Browse files
📝 Add docstrings to feat/import-subtitle-from-stream
Docstrings generation was requested by @mkdir700. * #221 (comment) The following files were modified: * `src/main/ipc.ts` * `src/renderer/src/pages/player/PlayerPage.tsx` * `src/renderer/src/pages/player/components/SubtitleListPanel.tsx`
1 parent 629af64 commit d192bed

3 files changed

Lines changed: 29 additions & 26 deletions

File tree

src/main/ipc.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ const mediaParserService = new MediaParserService()
4545
const subtitleExtractorService = new SubtitleExtractorService()
4646

4747
/**
48-
* Register all IPC handlers used by the main process.
48+
* Registers all ipcMain handlers used by the main process.
4949
*
50-
* Initializes updater and notification services and wires a comprehensive set of ipcMain.handle
51-
* handlers exposing application control, system info, theming/language, spell-check, cache and
52-
* file operations, dictionary lookups, FFmpeg operations, shortcut management, and database DAOs
53-
* (Files, VideoLibrary, SubtitleLibrary) to renderer processes.
50+
* Exposes application control, system information, theming/language, spell-check, cache and file
51+
* operations, media tooling (FFmpeg, media parser, subtitle extraction), shortcuts, and database
52+
* DAOs to renderer processes via ipcMain handlers.
5453
*
55-
* This function has side effects: it registers handlers on ipcMain, may attach an app 'before-quit'
56-
* listener when requested, and mutates Electron state (e.g., app paths, sessions). Call from the
57-
* Electron main process once (typically during app initialization).
54+
* This function mutates Electron state (registers handlers on ipcMain, may add/remove an app
55+
* 'before-quit' listener, and updates sessions/paths) and must be invoked once from the main
56+
* process during application initialization.
5857
*/
5958
export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
6059
const appUpdater = new AppUpdater(mainWindow)
@@ -1132,4 +1131,4 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
11321131
// throw error
11331132
// }
11341133
// })
1135-
}
1134+
}

src/renderer/src/pages/player/PlayerPage.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,15 @@ interface VideoData {
6565
}
6666

6767
/**
68-
* Player page component that loads a video by ID from the route and renders the video player UI.
68+
* Render the player page for the video identified by the current route and manage its loading,
69+
* transcoding session, subtitle detection, and related UI state.
6970
*
70-
* This component:
71-
* - Reads the `id` route parameter and loads the corresponding video record and file from the database.
72-
* - Constructs a file:// URL as the video source, stores per-page VideoData in local state and synchronizes it to the global per-video session store.
73-
* - Renders a top navbar with a back button and title, a two-pane Splitter layout with the video surface and controls on the left and a subtitle list on the right, and a settings popover.
74-
* - Shows a centered loading view while fetching data and an error view with a back button if loading fails or the video is missing.
75-
* - Cleans up the per-video session state on unmount.
71+
* Loads the video record and associated file, determines an appropriate playback source (original
72+
* file or HLS from a transcoding session), synchronizes per-video state with global stores,
73+
* detects embedded subtitle streams from the original file, and performs cleanup (including
74+
* deleting any created transcoding session) when the component unmounts.
7675
*
77-
* Side effects:
78-
* - Performs async data fetches from the VideoLibraryService and the app database.
79-
* - Updates a global player session store with the loaded VideoData and clears it when the component unmounts.
80-
*
81-
* Error handling:
82-
* - Loading or playback errors set local error state and cause the component to render the error view.
83-
*
84-
* Note: This is a React component (returns JSX) and does not accept props; it derives the target video ID from route params.
76+
* @returns The React element for the player page for the requested video
8577
*/
8678
function PlayerPage() {
8779
const navigate = useNavigate()
@@ -976,4 +968,4 @@ const ProgressBarArea = styled.div`
976968

977969
const BottomBar = styled.div`
978970
flex: 0 0 auto;
979-
`
971+
`

src/renderer/src/pages/player/components/SubtitleListPanel.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ type SubtitleSearchResult = {
4444
index: number
4545
}
4646

47+
/**
48+
* Render the subtitle list panel with search, virtualized list, and empty-state actions.
49+
*
50+
* Renders either an empty-state view with import/embedded/AI options and legacy actions when no subtitles are available,
51+
* or a searchable, virtualized list of subtitles with time formatting, range-based scrolling state management, and item selection.
52+
*
53+
* @param emptyDescription - Optional custom description to display in the empty-state header.
54+
* @param emptyActions - Optional list of custom action buttons to show in the empty-state legacy actions row.
55+
* @param hasEmbeddedSubtitles - When true, show the embedded-subtitle option card in the empty state.
56+
* @param onOpenEmbeddedSubtitleSelector - Callback invoked when the embedded-subtitle option's "select" button is clicked.
57+
* @returns The subtitle list panel element.
58+
*/
4759
function SubtitleListPanel({
4860
emptyDescription,
4961
emptyActions,
@@ -823,4 +835,4 @@ const SearchResultsHeader = styled.div`
823835
border-bottom: 1px solid var(--color-border-soft, rgba(255, 255, 255, 0.04));
824836
flex-shrink: 0;
825837
letter-spacing: 0.2px;
826-
`
838+
`

0 commit comments

Comments
 (0)