Made the episode request better

This commit is contained in:
tidusjar 2016-08-16 20:56:07 +01:00
parent 87f343ef06
commit f0c538ca64
2 changed files with 15 additions and 9 deletions

View file

@ -576,10 +576,11 @@ $(function () {
// Save Modal click // Save Modal click
$("#episodesRequest").click(function (e) { $("#episodesRequest").click(function (e) {
e.preventDefault(); e.preventDefault();
loadingButton("episodesRequest", "primary");
var origHtml = $('#episodesRequest').html(); var origHtml = $('#episodesRequest').html();
var tvId = $('#selectedEpisodeId').val(); var tvId = $('#selectedEpisodeId').val();
loadingButton("episodesRequest", "primary");
var $form = $('#form' + tvId); var $form = $('#form' + tvId);
var model = []; var model = [];

View file

@ -300,8 +300,8 @@ namespace PlexRequests.UI.Modules
var allResults = await RequestService.GetAllAsync(); var allResults = await RequestService.GetAllAsync();
allResults = allResults.Where(x => x.Type == RequestType.TvShow); allResults = allResults.Where(x => x.Type == RequestType.TvShow);
var distinctResults = allResults.DistinctBy(x => x.ProviderId);
var dbTv = allResults.ToDictionary(x => x.ProviderId); var dbTv = distinctResults.ToDictionary(x => x.ProviderId);
if (!apiTv.Any()) if (!apiTv.Any())
{ {
@ -648,7 +648,7 @@ namespace PlexRequests.UI.Modules
// It's technically a new request now, so set the status to not approved. // It's technically a new request now, so set the status to not approved.
existingRequest.Approved = false; existingRequest.Approved = false;
return await AddUserToRequest(existingRequest, settings, fullShowName); return await AddUserToRequest(existingRequest, settings, fullShowName, true);
} }
// We have an episode that has not yet been requested, let's continue // We have an episode that has not yet been requested, let's continue
} }
@ -744,17 +744,22 @@ namespace PlexRequests.UI.Modules
return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}"); return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
} }
private async Task<Response> AddUserToRequest(RequestedModel existingRequest, PlexRequestSettings settings, string fullShowName) private async Task<Response> AddUserToRequest(RequestedModel existingRequest, PlexRequestSettings settings, string fullShowName, bool episodeReq = false)
{ {
// check if the current user is already marked as a requester for this show, if not, add them // check if the current user is already marked as a requester for this show, if not, add them
if (!existingRequest.UserHasRequested(Username)) if (!existingRequest.UserHasRequested(Username))
{ {
existingRequest.RequestedUsers.Add(Username); existingRequest.RequestedUsers.Add(Username);
} }
if (settings.UsersCanViewOnlyOwnRequests || episodeReq)
return await UpdateRequest(existingRequest, settings, settings.UsersCanViewOnlyOwnRequests {
? $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}" return
: $"{fullShowName} {Resources.UI.Search_AlreadyRequested}"); await
UpdateRequest(existingRequest, settings,
$"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}");
}
return await UpdateRequest(existingRequest, settings, $"{fullShowName} {Resources.UI.Search_AlreadyRequested}");
} }
private bool ShouldSendNotification(RequestType type, PlexRequestSettings prSettings) private bool ShouldSendNotification(RequestType type, PlexRequestSettings prSettings)