Moved season selection to a separate section

This commit is contained in:
ltctceplrm 2025-12-31 02:19:29 +01:00
parent 64e79265b8
commit 3e09f4191b

View file

@ -234,19 +234,37 @@ export default class MediaDbPlugin extends Plugin {
} }
// Only show the season select modal if the user searches for seasons // Only show the season select modal if the user searches for seasons
if (await this.handleSeasonSelectModal(types, selectResults)) {
return;
}
const confirmed = await this.modalHelper.openPreviewModal({ elements: selectResults }, async previewModalData => {
return previewModalData.confirmed;
});
if (!confirmed) {
return;
}
break;
}
await this.createMediaDbNotes(selectResults!);
}
// Season select modal
private async handleSeasonSelectModal(types: string[], selectResults: MediaTypeModel[]): Promise<boolean> {
if (types.length === 1 && types[0] === 'season' && selectResults.length === 1 && selectResults[0].dataSource === 'TMDBSeasonAPI') { if (types.length === 1 && types[0] === 'season' && selectResults.length === 1 && selectResults[0].dataSource === 'TMDBSeasonAPI') {
// Dynamically import the modal // Dynamically import the modal
const { MediaDbSeasonSelectModal } = await import('./modals/MediaDbSeasonSelectModal'); const { MediaDbSeasonSelectModal } = await import('./modals/MediaDbSeasonSelectModal');
const TMDBSeasonAPI = this.apiManager.getApiByName('TMDBSeasonAPI') as import('./api/apis/TMDBSeasonAPI').TMDBSeasonAPI; const TMDBSeasonAPI = this.apiManager.getApiByName('TMDBSeasonAPI') as import('./api/apis/TMDBSeasonAPI').TMDBSeasonAPI;
if (!TMDBSeasonAPI) { if (!TMDBSeasonAPI) {
new Notice('TMDBSeasonAPI not found.'); new Notice('TMDBSeasonAPI not found.');
return; return true;
} }
// Fetch all seasons for the selected series // Fetch all seasons for the selected series
const allSeasons = await TMDBSeasonAPI.getSeasonsForSeries(selectResults[0].id); const allSeasons = await TMDBSeasonAPI.getSeasonsForSeries(selectResults[0].id);
if (!allSeasons || allSeasons.length === 0) { if (!allSeasons || allSeasons.length === 0) {
new Notice('No seasons found for this series.'); new Notice('No seasons found for this series.');
return; return true;
} }
// Pass the original series title from the search result // Pass the original series title from the search result
const seriesName = selectResults[0]?.englishTitle || selectResults[0]?.title || ''; const seriesName = selectResults[0]?.englishTitle || selectResults[0]?.title || '';
@ -267,9 +285,9 @@ export default class MediaDbPlugin extends Plugin {
modal.open(); modal.open();
}); });
if (!selectedSeasons || selectedSeasons.length === 0) { if (!selectedSeasons || selectedSeasons.length === 0) {
return; return true;
} }
// Fetch full metadata for each selected seasond and create the note // Fetch full metadata for each selected season and create the note
await Promise.all( await Promise.all(
selectedSeasons.map(async season => { selectedSeasons.map(async season => {
const orig = allSeasons.find(s => s.seasonNumber === season.season_number); const orig = allSeasons.find(s => s.seasonNumber === season.season_number);
@ -285,19 +303,9 @@ export default class MediaDbPlugin extends Plugin {
} }
}), }),
); );
return; return true;
} }
return false;
const confirmed = await this.modalHelper.openPreviewModal({ elements: selectResults }, async previewModalData => {
return previewModalData.confirmed;
});
if (!confirmed) {
return;
}
break;
}
await this.createMediaDbNotes(selectResults!);
} }
async createEntryWithAdvancedSearchModal(): Promise<void> { async createEntryWithAdvancedSearchModal(): Promise<void> {