Moved season selection to a separate section
This commit is contained in:
parent
64e79265b8
commit
3e09f4191b
1 changed files with 59 additions and 51 deletions
40
src/main.ts
40
src/main.ts
|
|
@ -234,19 +234,37 @@ export default class MediaDbPlugin extends Plugin {
|
|||
}
|
||||
|
||||
// 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') {
|
||||
// Dynamically import the modal
|
||||
const { MediaDbSeasonSelectModal } = await import('./modals/MediaDbSeasonSelectModal');
|
||||
const TMDBSeasonAPI = this.apiManager.getApiByName('TMDBSeasonAPI') as import('./api/apis/TMDBSeasonAPI').TMDBSeasonAPI;
|
||||
if (!TMDBSeasonAPI) {
|
||||
new Notice('TMDBSeasonAPI not found.');
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
// Fetch all seasons for the selected series
|
||||
const allSeasons = await TMDBSeasonAPI.getSeasonsForSeries(selectResults[0].id);
|
||||
if (!allSeasons || allSeasons.length === 0) {
|
||||
new Notice('No seasons found for this series.');
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
// Pass the original series title from the search result
|
||||
const seriesName = selectResults[0]?.englishTitle || selectResults[0]?.title || '';
|
||||
|
|
@ -267,9 +285,9 @@ export default class MediaDbPlugin extends Plugin {
|
|||
modal.open();
|
||||
});
|
||||
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(
|
||||
selectedSeasons.map(async season => {
|
||||
const orig = allSeasons.find(s => s.seasonNumber === season.season_number);
|
||||
|
|
@ -285,19 +303,9 @@ export default class MediaDbPlugin extends Plugin {
|
|||
}
|
||||
}),
|
||||
);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
const confirmed = await this.modalHelper.openPreviewModal({ elements: selectResults }, async previewModalData => {
|
||||
return previewModalData.confirmed;
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await this.createMediaDbNotes(selectResults!);
|
||||
return false;
|
||||
}
|
||||
|
||||
async createEntryWithAdvancedSearchModal(): Promise<void> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue