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:
parent
c9f1e32c14
commit
31859aaa0b
2 changed files with 22 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue