mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
New: Refresh Selected in Editor Mode
This commit is contained in:
parent
135251ec31
commit
aa6c8f493e
@ -281,6 +281,13 @@ class MovieIndex extends Component {
|
|||||||
this.setState({ isConfirmSearchModalOpen: true, searchType: 'moviesSearch' });
|
this.setState({ isConfirmSearchModalOpen: true, searchType: 'moviesSearch' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRefreshMoviePress = () => {
|
||||||
|
const selectedMovieIds = this.getSelectedIds();
|
||||||
|
const refreshIds = this.state.isMovieEditorActive && selectedMovieIds.length > 0 ? selectedMovieIds : [];
|
||||||
|
|
||||||
|
this.props.onRefreshMoviePress(refreshIds);
|
||||||
|
}
|
||||||
|
|
||||||
onSearchConfirmed = () => {
|
onSearchConfirmed = () => {
|
||||||
const selectedMovieIds = this.getSelectedIds();
|
const selectedMovieIds = this.getSelectedIds();
|
||||||
const searchIds = this.state.isMovieEditorActive && selectedMovieIds.length > 0 ? selectedMovieIds : this.props.items.map((m) => m.id);
|
const searchIds = this.state.isMovieEditorActive && selectedMovieIds.length > 0 ? selectedMovieIds : this.props.items.map((m) => m.id);
|
||||||
@ -356,12 +363,12 @@ class MovieIndex extends Component {
|
|||||||
<PageToolbar>
|
<PageToolbar>
|
||||||
<PageToolbarSection>
|
<PageToolbarSection>
|
||||||
<PageToolbarButton
|
<PageToolbarButton
|
||||||
label="Update all"
|
label={isMovieEditorActive && selectedMovieIds.length > 0 ? 'Update Selected' : 'Update All'}
|
||||||
iconName={icons.REFRESH}
|
iconName={icons.REFRESH}
|
||||||
spinningName={icons.REFRESH}
|
spinningName={icons.REFRESH}
|
||||||
isSpinning={isRefreshingMovie}
|
isSpinning={isRefreshingMovie}
|
||||||
isDisabled={hasNoMovie}
|
isDisabled={hasNoMovie}
|
||||||
onPress={onRefreshMoviePress}
|
onPress={this.onRefreshMoviePress}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageToolbarButton
|
<PageToolbarButton
|
||||||
|
@ -69,9 +69,10 @@ function createMapDispatchToProps(dispatch, props) {
|
|||||||
dispatch(saveMovieEditor(payload));
|
dispatch(saveMovieEditor(payload));
|
||||||
},
|
},
|
||||||
|
|
||||||
onRefreshMoviePress() {
|
onRefreshMoviePress(items) {
|
||||||
dispatch(executeCommand({
|
dispatch(executeCommand({
|
||||||
name: commandNames.REFRESH_MOVIE
|
name: commandNames.REFRESH_MOVIE,
|
||||||
|
movieIds: items
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public void should_update_imdb_id_if_changed()
|
|||||||
|
|
||||||
GivenNewMovieInfo(newMovieInfo);
|
GivenNewMovieInfo(newMovieInfo);
|
||||||
|
|
||||||
Subject.Execute(new RefreshMovieCommand(_movie.Id));
|
Subject.Execute(new RefreshMovieCommand(new List<int> { _movie.Id }));
|
||||||
|
|
||||||
Mocker.GetMock<IMovieService>()
|
Mocker.GetMock<IMovieService>()
|
||||||
.Verify(v => v.UpdateMovie(It.Is<List<Movie>>(s => s.First().ImdbId == newMovieInfo.ImdbId), true));
|
.Verify(v => v.UpdateMovie(It.Is<List<Movie>>(s => s.First().ImdbId == newMovieInfo.ImdbId), true));
|
||||||
@ -60,7 +60,7 @@ public void should_update_imdb_id_if_changed()
|
|||||||
[Test]
|
[Test]
|
||||||
public void should_log_error_if_tmdb_id_not_found()
|
public void should_log_error_if_tmdb_id_not_found()
|
||||||
{
|
{
|
||||||
Subject.Execute(new RefreshMovieCommand(_movie.Id));
|
Subject.Execute(new RefreshMovieCommand(new List<int> { _movie.Id }));
|
||||||
|
|
||||||
Mocker.GetMock<IMovieService>()
|
Mocker.GetMock<IMovieService>()
|
||||||
.Verify(v => v.UpdateMovie(It.Is<Movie>(s => s.Status == MovieStatusType.Deleted)), Times.Once());
|
.Verify(v => v.UpdateMovie(It.Is<Movie>(s => s.Status == MovieStatusType.Deleted)), Times.Once());
|
||||||
@ -76,7 +76,7 @@ public void should_update_if_tmdb_id_changed()
|
|||||||
|
|
||||||
GivenNewMovieInfo(newMovieInfo);
|
GivenNewMovieInfo(newMovieInfo);
|
||||||
|
|
||||||
Subject.Execute(new RefreshMovieCommand(_movie.Id));
|
Subject.Execute(new RefreshMovieCommand(new List<int> { _movie.Id }));
|
||||||
|
|
||||||
Mocker.GetMock<IMovieService>()
|
Mocker.GetMock<IMovieService>()
|
||||||
.Verify(v => v.UpdateMovie(It.Is<List<Movie>>(s => s.First().TmdbId == newMovieInfo.TmdbId), true));
|
.Verify(v => v.UpdateMovie(It.Is<List<Movie>>(s => s.First().TmdbId == newMovieInfo.TmdbId), true));
|
||||||
@ -87,7 +87,7 @@ public void should_update_if_tmdb_id_changed()
|
|||||||
[Test]
|
[Test]
|
||||||
public void should_mark_as_deleted_if_tmdb_id_not_found()
|
public void should_mark_as_deleted_if_tmdb_id_not_found()
|
||||||
{
|
{
|
||||||
Subject.Execute(new RefreshMovieCommand(_movie.Id));
|
Subject.Execute(new RefreshMovieCommand(new List<int> { _movie.Id }));
|
||||||
|
|
||||||
Mocker.GetMock<IMovieService>()
|
Mocker.GetMock<IMovieService>()
|
||||||
.Verify(v => v.UpdateMovie(It.Is<Movie>(s => s.Status == MovieStatusType.Deleted)), Times.Once());
|
.Verify(v => v.UpdateMovie(It.Is<Movie>(s => s.Status == MovieStatusType.Deleted)), Times.Once());
|
||||||
@ -100,7 +100,7 @@ public void should_not_remark_as_deleted_if_tmdb_id_not_found()
|
|||||||
{
|
{
|
||||||
_movie.Status = MovieStatusType.Deleted;
|
_movie.Status = MovieStatusType.Deleted;
|
||||||
|
|
||||||
Subject.Execute(new RefreshMovieCommand(_movie.Id));
|
Subject.Execute(new RefreshMovieCommand(new List<int> { _movie.Id }));
|
||||||
|
|
||||||
Mocker.GetMock<IMovieService>()
|
Mocker.GetMock<IMovieService>()
|
||||||
.Verify(v => v.UpdateMovie(It.IsAny<Movie>()), Times.Never());
|
.Verify(v => v.UpdateMovie(It.IsAny<Movie>()), Times.Never());
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Movies.Commands
|
namespace NzbDrone.Core.Movies.Commands
|
||||||
{
|
{
|
||||||
public class RefreshMovieCommand : Command
|
public class RefreshMovieCommand : Command
|
||||||
{
|
{
|
||||||
public int? MovieId { get; set; }
|
public List<int> MovieIds { get; set; }
|
||||||
public bool IsNewMovie { get; set; }
|
public bool IsNewMovie { get; set; }
|
||||||
|
|
||||||
public RefreshMovieCommand()
|
public RefreshMovieCommand()
|
||||||
{
|
{
|
||||||
|
MovieIds = new List<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefreshMovieCommand(int? movieId, bool isNewMovie = false)
|
public RefreshMovieCommand(List<int> movieIds, bool isNewMovie = false)
|
||||||
{
|
{
|
||||||
MovieId = movieId;
|
MovieIds = movieIds;
|
||||||
IsNewMovie = isNewMovie;
|
IsNewMovie = isNewMovie;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool SendUpdatesToClient => true;
|
public override bool SendUpdatesToClient => true;
|
||||||
|
|
||||||
public override bool UpdateScheduledTask => !MovieId.HasValue;
|
public override bool UpdateScheduledTask => !MovieIds.Any();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
@ -17,12 +18,12 @@ public MovieAddedHandler(IManageCommandQueue commandQueueManager)
|
|||||||
|
|
||||||
public void Handle(MovieAddedEvent message)
|
public void Handle(MovieAddedEvent message)
|
||||||
{
|
{
|
||||||
_commandQueueManager.Push(new RefreshMovieCommand(message.Movie.Id, true));
|
_commandQueueManager.Push(new RefreshMovieCommand(new List<int> { message.Movie.Id }, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(MoviesImportedEvent message)
|
public void Handle(MoviesImportedEvent message)
|
||||||
{
|
{
|
||||||
_commandQueueManager.PushMany(message.MovieIds.Select(s => new RefreshMovieCommand(s, true)).ToList());
|
_commandQueueManager.PushMany(message.MovieIds.Select(s => new RefreshMovieCommand(new List<int> { s }, true)).ToList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,24 +178,27 @@ public void Execute(RefreshMovieCommand message)
|
|||||||
var isNew = message.IsNewMovie;
|
var isNew = message.IsNewMovie;
|
||||||
_eventAggregator.PublishEvent(new MovieRefreshStartingEvent(message.Trigger == CommandTrigger.Manual));
|
_eventAggregator.PublishEvent(new MovieRefreshStartingEvent(message.Trigger == CommandTrigger.Manual));
|
||||||
|
|
||||||
if (message.MovieId.HasValue)
|
if (message.MovieIds.Any())
|
||||||
{
|
{
|
||||||
var movie = _movieService.GetMovie(message.MovieId.Value);
|
foreach (var movieId in message.MovieIds)
|
||||||
|
{
|
||||||
|
var movie = _movieService.GetMovie(movieId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RefreshMovieInfo(movie);
|
RefreshMovieInfo(movie);
|
||||||
RescanMovie(movie, isNew, trigger);
|
RescanMovie(movie, isNew, trigger);
|
||||||
}
|
}
|
||||||
catch (MovieNotFoundException)
|
catch (MovieNotFoundException)
|
||||||
{
|
{
|
||||||
_logger.Error("Movie '{0}' (imdbid {1}) was not found, it may have been removed from The Movie Database.", movie.Title, movie.ImdbId);
|
_logger.Error("Movie '{0}' (imdbid {1}) was not found, it may have been removed from The Movie Database.", movie.Title, movie.ImdbId);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "Couldn't refresh info for {0}", movie);
|
_logger.Error(e, "Couldn't refresh info for {0}", movie);
|
||||||
RescanMovie(movie, isNew, trigger);
|
RescanMovie(movie, isNew, trigger);
|
||||||
throw;
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -305,7 +305,7 @@ public MovieFileResource EnsureMovieFile(MovieResource movie, Quality quality)
|
|||||||
//File.Copy(sourcePath, path);
|
//File.Copy(sourcePath, path);
|
||||||
File.WriteAllText(path, "Fake Movie");
|
File.WriteAllText(path, "Fake Movie");
|
||||||
|
|
||||||
Commands.PostAndWait(new RefreshMovieCommand(movie.Id));
|
Commands.PostAndWait(new RefreshMovieCommand(new List<int> { movie.Id }));
|
||||||
Commands.WaitAll();
|
Commands.WaitAll();
|
||||||
|
|
||||||
result = Movies.Get(movie.Id);
|
result = Movies.Get(movie.Id);
|
||||||
|
Loading…
Reference in New Issue
Block a user