Fixed download actionable missing in some cases due to a failed admin check.

Fixed download missing on series-detail page.
This commit is contained in:
Joseph Milazzo 2025-06-03 04:53:12 -05:00
parent c9f1e32c14
commit 31859aaa0b
2 changed files with 22 additions and 5 deletions

View file

@ -102,11 +102,22 @@ export class AccountService {
return true;
}
/**
* If the user has any role in the restricted roles array or is an Admin
* @param user
* @param roles
* @param restrictedRoles
*/
hasAnyRole(user: User, roles: Array<Role>, restrictedRoles: Array<Role> = []) {
if (!user || !user.roles) {
return false;
}
// If the user is an admin, they have the role
if (this.hasAdminRole(user)) {
return true;
}
// If restricted roles are provided and the user has any of them, deny access
if (restrictedRoles.length > 0 && restrictedRoles.some(role => user.roles.includes(role))) {
return false;

View file

@ -551,7 +551,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
this.location.replaceState(newUrl)
}
handleSeriesActionCallback(action: ActionItem<Series>, series: Series) {
async handleSeriesActionCallback(action: ActionItem<Series>, series: Series) {
this.cdRef.markForCheck();
switch(action.action) {
case(Action.MarkAsRead):
@ -565,16 +565,16 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
});
break;
case(Action.Scan):
this.actionService.scanSeries(series);
await this.actionService.scanSeries(series);
break;
case(Action.RefreshMetadata):
this.actionService.refreshSeriesMetadata(series, undefined, true, false);
await this.actionService.refreshSeriesMetadata(series, undefined, true, false);
break;
case(Action.GenerateColorScape):
this.actionService.refreshSeriesMetadata(series, undefined, false, true);
await this.actionService.refreshSeriesMetadata(series, undefined, false, true);
break;
case(Action.Delete):
this.deleteSeries(series);
await this.deleteSeries(series);
break;
case(Action.AddToReadingList):
this.actionService.addSeriesToReadingList(series);
@ -645,6 +645,9 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
this.actionService.sendToDevice(volume.chapters.map(c => c.id), device);
break;
}
case (Action.Download):
this.downloadService.download('volume', volume);
break;
default:
break;
}
@ -679,6 +682,9 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked {
this.cdRef.markForCheck();
});
break;
case (Action.Download):
this.downloadService.download('chapter', chapter);
break;
default:
break;
}