mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-16 10:58:31 -05:00
Fix changes not being preserved
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using FeedCenter.Properties;
|
||||||
|
|
||||||
namespace FeedCenter
|
namespace FeedCenter
|
||||||
{
|
{
|
||||||
@@ -78,7 +79,7 @@ namespace FeedCenter
|
|||||||
_currentCategory = category;
|
_currentCategory = category;
|
||||||
|
|
||||||
// Get the current feed list to match the category
|
// Get the current feed list to match the category
|
||||||
_feedList = _currentCategory?.Feeds.ToList() ?? _database.Feeds.ToList();
|
_feedList = _currentCategory == null ? _database.Feeds : _database.Feeds.Where(feed => feed.Category.ID == _currentCategory.ID);
|
||||||
|
|
||||||
// Reset the feed index
|
// Reset the feed index
|
||||||
_feedIndex = -1;
|
_feedIndex = -1;
|
||||||
@@ -92,6 +93,8 @@ namespace FeedCenter
|
|||||||
// Update the display
|
// Update the display
|
||||||
DisplayCategory();
|
DisplayCategory();
|
||||||
DisplayFeed();
|
DisplayFeed();
|
||||||
|
|
||||||
|
Settings.Default.LastCategoryID = _currentCategory?.ID.ToString() ?? string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Common.IO;
|
|||||||
using Common.Update;
|
using Common.Update;
|
||||||
using FeedCenter.Properties;
|
using FeedCenter.Properties;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -19,7 +18,7 @@ namespace FeedCenter
|
|||||||
private int _feedIndex;
|
private int _feedIndex;
|
||||||
|
|
||||||
private Category _currentCategory;
|
private Category _currentCategory;
|
||||||
private ICollection<Feed> _feedList;
|
private IQueryable<Feed> _feedList;
|
||||||
private Feed _currentFeed;
|
private Feed _currentFeed;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@@ -120,7 +119,7 @@ namespace FeedCenter
|
|||||||
private void UpdateToolbarButtonState()
|
private void UpdateToolbarButtonState()
|
||||||
{
|
{
|
||||||
// Cache the feed count to save (a little) time
|
// Cache the feed count to save (a little) time
|
||||||
var feedCount = _feedList?.Count ?? 0;
|
var feedCount = _feedList?.Count() ?? 0;
|
||||||
|
|
||||||
// Set button states
|
// Set button states
|
||||||
PreviousToolbarButton.IsEnabled = (feedCount > 1);
|
PreviousToolbarButton.IsEnabled = (feedCount > 1);
|
||||||
@@ -141,7 +140,7 @@ namespace FeedCenter
|
|||||||
DisplayCategory();
|
DisplayCategory();
|
||||||
|
|
||||||
// Get the current feed list to match the category
|
// Get the current feed list to match the category
|
||||||
_feedList = _currentCategory?.Feeds.ToList() ?? _database.Feeds.ToList();
|
_feedList = _currentCategory == null ? _database.Feeds : _database.Feeds.Where(feed => feed.Category.ID == _currentCategory.ID);
|
||||||
|
|
||||||
UpdateToolbarButtonState();
|
UpdateToolbarButtonState();
|
||||||
|
|
||||||
@@ -155,7 +154,7 @@ namespace FeedCenter
|
|||||||
StartTimer();
|
StartTimer();
|
||||||
|
|
||||||
// Don't go further if we have no feeds
|
// Don't go further if we have no feeds
|
||||||
if (_feedList.Count == 0)
|
if (!_feedList.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the first feed
|
// Get the first feed
|
||||||
@@ -364,6 +363,8 @@ namespace FeedCenter
|
|||||||
// Create a new database object
|
// Create a new database object
|
||||||
_database = new FeedCenterEntities();
|
_database = new FeedCenterEntities();
|
||||||
|
|
||||||
|
_feedList = _currentCategory == null ? _database.Feeds : _database.Feeds.Where(feed => feed.Category.ID == _currentCategory.ID);
|
||||||
|
|
||||||
UpdateToolbarButtonState();
|
UpdateToolbarButtonState();
|
||||||
|
|
||||||
// Get a list of feeds ordered by name
|
// Get a list of feeds ordered by name
|
||||||
|
|||||||
Reference in New Issue
Block a user