diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index 73ddc6f23..0cd5aba48 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -576,10 +576,11 @@ $(function () { // Save Modal click $("#episodesRequest").click(function (e) { e.preventDefault(); + + loadingButton("episodesRequest", "primary"); var origHtml = $('#episodesRequest').html(); var tvId = $('#selectedEpisodeId').val(); - loadingButton("episodesRequest", "primary"); var $form = $('#form' + tvId); var model = []; diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 39ec35cf3..5f0fa4ed1 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -300,8 +300,8 @@ namespace PlexRequests.UI.Modules var allResults = await RequestService.GetAllAsync(); allResults = allResults.Where(x => x.Type == RequestType.TvShow); - - var dbTv = allResults.ToDictionary(x => x.ProviderId); + var distinctResults = allResults.DistinctBy(x => x.ProviderId); + var dbTv = distinctResults.ToDictionary(x => x.ProviderId); 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. 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 } @@ -744,17 +744,22 @@ namespace PlexRequests.UI.Modules return await AddRequest(model, settings, $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}"); } - private async Task AddUserToRequest(RequestedModel existingRequest, PlexRequestSettings settings, string fullShowName) + private async Task 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 if (!existingRequest.UserHasRequested(Username)) { existingRequest.RequestedUsers.Add(Username); } - - return await UpdateRequest(existingRequest, settings, settings.UsersCanViewOnlyOwnRequests - ? $"{fullShowName} {Resources.UI.Search_SuccessfullyAdded}" - : $"{fullShowName} {Resources.UI.Search_AlreadyRequested}"); + if (settings.UsersCanViewOnlyOwnRequests || episodeReq) + { + return + 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)