Permalink
Browse files

Removed unnecessary rereshing from unrecognized series.

  • Loading branch information...
bond4u committed Mar 10, 2018
1 parent 74e3c51 commit 4d58eb7b80ec05f076fbf8f5843e8666168f5095
Showing with 24 additions and 21 deletions.
  1. +4 −2 Shoko.Desktop/MainWindow.xaml.cs
  2. +20 −19 Shoko.Desktop/UserControls/UnrecognisedVideos.xaml.cs
@@ -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:
@@ -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;
@@ -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)
{
@@ -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)
@@ -555,7 +558,6 @@ void btnConfirm_Click(object sender, RoutedEventArgs e)
finally
{
EnableDisableControls(true);
RefreshSeriesList();
}
}
@@ -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
{
@@ -943,7 +948,7 @@ public void RefreshSeries()
{
SearchAnime(dgVideos.SelectedItems);
}
else
else if (all)
{
SearchAnime(null);
}
@@ -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);
@@ -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
{
@@ -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;
}
}

0 comments on commit 4d58eb7

Please sign in to comment.