Permalink
Browse files

shift validation logic if TvDB Data has already arrived while adding …

…those links, so that it finally takes effect
  • Loading branch information...
Baine committed Feb 7, 2018
1 parent 7631de9 commit 62ec7807ebeacb5c5a1d2dfd794d7f0453fe3dd4
Showing with 52 additions and 23 deletions.
  1. +52 −15 Shoko.Desktop/Forms/SearchTvDBForm.xaml.cs
  2. +0 −8 Shoko.Desktop/Forms/SelectTvDBSeasonForm.xaml.cs
@@ -91,6 +91,22 @@ public string AnimeName
public int? SelectedTvDBID;
private VM_AniDB_Anime Anime;

private bool tvDbDataReady(int id)
{

VM_ShokoServer.Instance.ShokoServices.UpdateTvDBData(id);
VM_TvDBDetails TvDetails = new VM_TvDBDetails(id);
if (TvDetails.TvDBEpisodes == null || TvDetails.TvDBEpisodes.Count <= 0)
{
return false;
}
else
{
return true;
}

}

public SearchTvDBForm()
{
InitializeComponent();
@@ -140,15 +156,24 @@ void btnUseThisExisting_Click(object sender, RoutedEventArgs e)

Cursor = Cursors.Wait;
frm.Owner = wdw;
frm.Init(AnimeID, AnimeName, EpisodeType.Episode, 1, id, 1, 1, AnimeName, Anime, !ReplaceAll);
bool? result = frm.ShowDialog();
if (result != null && result.Value)

if (!tvDbDataReady(id))
{
SelectedTvDBID = id;
DialogResult = true;
Cursor = Cursors.Arrow;
Close();
Utils.ShowErrorMessage("The series data is being downloaded, try again when the queue has cleared.");
return;
}
else
{
frm.Init(AnimeID, AnimeName, EpisodeType.Episode, 1, id, 1, 1, AnimeName, Anime, !ReplaceAll);
bool? result = frm.ShowDialog();
if (result != null && result.Value)
{
SelectedTvDBID = id;
DialogResult = true;
Cursor = Cursors.Arrow;
Close();
}
}
}
catch (Exception ex)
{
@@ -227,16 +252,28 @@ private void CommandBinding_UseThis(object sender, ExecutedRoutedEventArgs e)

Cursor = Cursors.Wait;
SelectTvDBSeasonForm frm = new SelectTvDBSeasonForm {Owner = wdw};
frm.Init(AnimeID, AnimeName, EpisodeType.Episode, 1, searchResult.SeriesID, 1, 1,
searchResult.SeriesName, Anime, !ReplaceAll);
bool? result = frm.ShowDialog();
if (result != null && result.Value)

if (!tvDbDataReady(searchResult.SeriesID))
{
SelectedTvDBID = searchResult.SeriesID;
DialogResult = true;
Cursor = Cursors.Arrow;
Close();
Utils.ShowErrorMessage("The series data is being downloaded, try again when the queue has cleared.");
return;
}
else
{
frm.Init(AnimeID, AnimeName, EpisodeType.Episode, 1, searchResult.SeriesID, 1, 1,
searchResult.SeriesName, Anime, !ReplaceAll);
bool? result = frm.ShowDialog();
if (result != null && result.Value)
{
SelectedTvDBID = searchResult.SeriesID;
DialogResult = true;
Cursor = Cursors.Arrow;
Close();
}

}


}
}
catch (Exception ex)
@@ -255,16 +255,8 @@ void btnClose_Click(object sender, RoutedEventArgs e)
}
else
{
VM_ShokoServer.Instance.ShokoServices.UpdateTvDBData(tvDBID);
TvDetails = new VM_TvDBDetails(tvDBID);
if (TvDetails.TvDBEpisodes == null || TvDetails.TvDBEpisodes.Count <= 0)
{
Utils.ShowErrorMessage("The series data is being downloaded, try again when the queue has cleared.");
DialogResult = false;
Close();
}
seasons = TvDetails.DictTvDBSeasons.Keys.ToList();
//seasons = VM_ShokoServer.Instance.clientBinaryHTTP.GetSeasonNumbersForSeries(tvDBID);
}

int i = 0;

0 comments on commit 62ec780

Please sign in to comment.