Skip to content

Commit

Permalink
Merge pull request #584 from bond4u/unrec_series_refresh
Browse files Browse the repository at this point in the history
Removed unnecessary refreshing from unrecognized series.
  • Loading branch information
da3dsoul committed Mar 10, 2018
2 parents 74e3c51 + 4d58eb7 commit e4f2579
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
6 changes: 4 additions & 2 deletions Shoko.Desktop/MainWindow.xaml.cs
Expand Up @@ -552,8 +552,10 @@ private void tabFileManager_SelectionChanged(object sender, SelectionChangedEven
switch (tab.SelectedIndex)
{
case (int) TAB_UTILITY.Unrecognised:
if (unRecVids.UnrecognisedFiles.Count == 0) unRecVids.RefreshUnrecognisedFiles();
if (unRecVids.AllSeries.Count == 0) unRecVids.RefreshSeries();
if (unRecVids.UnrecognisedFiles.Count == 0)
unRecVids.RefreshUnrecognisedFiles();
if (0==unRecVids.AllSeries.Count && string.IsNullOrEmpty(unRecVids.txtSeriesSearch.Text))
unRecVids.RefreshSeries(true); //inital all load
lastFileManagerTab = (int) TAB_UTILITY.Unrecognised;
break;
case (int) TAB_UTILITY.Ignored:
Expand Down
39 changes: 20 additions & 19 deletions Shoko.Desktop/UserControls/UnrecognisedVideos.xaml.cs
Expand Up @@ -165,13 +165,14 @@ public void Window_Loaded(object sender, RoutedEventArgs e)

OneVideoSelected = dgVideos.SelectedItems.Count == 1;
MultipleVideosSelected = dgVideos.SelectedItems.Count > 1;
RefreshSeries();
//window showed up and dashboard is visible, but every page is loading..
}

private void DgVideos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
bool isShiftOrCtrlDown = 0 != (Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control));
ccDetail.Content = null;
ccDetailMultiple.Content = null;

Expand Down Expand Up @@ -214,7 +215,10 @@ private void DgVideos_SelectionChanged(object sender, SelectionChangedEventArgs
}
SetConfirmDetails();
Confirm1.Visibility = Confirm2.Visibility = visible;
if (string.IsNullOrEmpty(txtSeriesSearch.Text)) RefreshSeries();
if (string.IsNullOrEmpty(txtSeriesSearch.Text) && !isShiftOrCtrlDown) {
//no user search and ignore shift- and control-clicks
RefreshSeries();
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -321,11 +325,10 @@ void btnAddSeries_Click(object sender, RoutedEventArgs e)
bool? result = frm.ShowDialog();
if (result.HasValue && result.Value)
{
//ok, now its safe to use textbox, search wont mess with it
RefreshSeries();

VM_AnimeSeries_User ser = frm.AnimeSeries;
txtSeriesSearch.Text =
ser?.AniDBAnime?.AniDBAnime?.FormattedTitle ?? ser?.SeriesName ?? string.Empty;
txtSeriesSearch.Text = ser?.AniDBAnime?.AniDBAnime?.FormattedTitle ?? ser?.SeriesName ?? string.Empty;
}
}
catch (Exception ex)
Expand Down Expand Up @@ -555,7 +558,6 @@ void btnConfirm_Click(object sender, RoutedEventArgs e)
finally
{
EnableDisableControls(true);
RefreshSeriesList();
}
}

Expand Down Expand Up @@ -924,15 +926,18 @@ public void RefreshUnrecognisedFiles()
{
UnrecognisedFiles.Add(vid);
}
RefreshSeries();
}
catch (Exception ex)
{
Utils.ShowErrorMessage(ex);
}
}

public void RefreshSeries()
//use cases:
//1. load what is selected if files grid
//2. initial fetch to fill AllSeries list
//3. load series that was just added
public void RefreshSeries(bool all=false)
{
try
{
Expand All @@ -943,7 +948,7 @@ public void RefreshSeries()
{
SearchAnime(dgVideos.SelectedItems);
}
else
else if (all)
{
SearchAnime(null);
}
Expand Down Expand Up @@ -973,7 +978,6 @@ public async void SearchAnime(object argument)

Progress<List<VM_AnimeSeries_User>> progress = new Progress<List<VM_AnimeSeries_User>>(ReportProgress);

AllSeries.Clear();
await Task.Run(() =>
{
SearchAnime(token, argument, progress);
Expand Down Expand Up @@ -1075,13 +1079,13 @@ public void ReportProgress(List<VM_AnimeSeries_User> series)
{
if (series == null || series.Count <= 0)
{
txtSeriesSearch.Text = string.Intern("Loading...");
//dont mess with user input
txtSeriesSearch.IsEnabled = false;
txtSeriesSearch.IsReadOnly = true;
txtSeriesSearch.Focusable = false;

lbSeries.IsEnabled = false;
AllSeries.Clear();
//use listbox with dummy instead
VM_AnimeSeries_User dummy = new VM_AnimeSeries_User();
dummy.SeriesNameOverride = "Loading...";
AllSeries.Add(dummy);
}
else
{
Expand All @@ -1090,11 +1094,8 @@ public void ReportProgress(List<VM_AnimeSeries_User> series)

if (AllSeries.Count >= 1)
lbSeries.SelectedIndex = 0;
txtSeriesSearch.IsReadOnly = false;
txtSeriesSearch.Focusable = true;
txtSeriesSearch.Text = string.Empty;
txtSeriesSearch.IsEnabled = true;

txtSeriesSearch.IsEnabled = true;
lbSeries.IsEnabled = true;
}
}
Expand Down

0 comments on commit e4f2579

Please sign in to comment.