Revert: only call notifyPropertyChanged if actually set to new value

This commit is contained in:
Robert McRackan 2022-05-14 12:34:01 -04:00
parent 9bdcaa5eaa
commit 28a8b2e685
2 changed files with 13 additions and 42 deletions

View File

@ -135,14 +135,11 @@ namespace LibationWinForms.Dialogs
return _remove; return _remove;
} }
set set
{
if (_remove != value)
{ {
_remove = value; _remove = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
}
public override object GetMemberValue(string memberName) public override object GetMemberValue(string memberName)
{ {

View File

@ -40,14 +40,11 @@ namespace LibationWinForms
{ {
get => _cover; get => _cover;
private set private set
{
if (_cover != value)
{ {
_cover = value; _cover = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
}
public bool DownloadInProgress { get; private set; } public bool DownloadInProgress { get; private set; }
public string ProductRating { get; private set; } public string ProductRating { get; private set; }
@ -175,25 +172,16 @@ namespace LibationWinForms
switch (itemName) switch (itemName)
{ {
case nameof(udi.Tags): case nameof(udi.Tags):
if (Book.UserDefinedItem.Tags != udi.Tags)
{
Book.UserDefinedItem.Tags = udi.Tags; Book.UserDefinedItem.Tags = udi.Tags;
NotifyPropertyChanged(nameof(DisplayTags)); NotifyPropertyChanged(nameof(DisplayTags));
}
break; break;
case nameof(udi.BookStatus): case nameof(udi.BookStatus):
if (Book.UserDefinedItem.BookStatus != udi.BookStatus)
{
Book.UserDefinedItem.BookStatus = udi.BookStatus; Book.UserDefinedItem.BookStatus = udi.BookStatus;
NotifyPropertyChanged(nameof(Liberate)); NotifyPropertyChanged(nameof(Liberate));
}
break; break;
case nameof(udi.PdfStatus): case nameof(udi.PdfStatus):
if (Book.UserDefinedItem.PdfStatus != udi.PdfStatus)
{
Book.UserDefinedItem.PdfStatus = udi.PdfStatus; Book.UserDefinedItem.PdfStatus = udi.PdfStatus;
NotifyPropertyChanged(nameof(Liberate)); NotifyPropertyChanged(nameof(Liberate));
}
break; break;
} }
} }
@ -223,23 +211,9 @@ namespace LibationWinForms
private void UpdateLiberatedStatus(bool notify = true) private void UpdateLiberatedStatus(bool notify = true)
{ {
var changed = false; _bookStatus = LibraryCommands.Liberated_Status(LibraryBook.Book);
_pdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book);
var newBookStatus = LibraryCommands.Liberated_Status(LibraryBook.Book); if (notify)
if (_bookStatus != newBookStatus)
{
_bookStatus = newBookStatus;
changed = true;
}
var newPdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book);
if (_pdfStatus != newPdfStatus)
{
_pdfStatus = newPdfStatus;
changed = true;
}
if (changed && notify)
NotifyPropertyChanged(nameof(Liberate)); NotifyPropertyChanged(nameof(Liberate));
} }