Skip to content

Commit

Permalink
Hotfixing searchfornotes funciton
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahAlhariri committed Jun 16, 2024
1 parent d44df37 commit 22f1029
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions ViewModels/NotesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@ public async Task OnDisappearing()

public void SearchForNotes(object? sender, EventArgs eventArgs)
{
// SearchBar searchBar = (SearchBar)sender;
// var searchKeyword = searchBar.Text;
//
// if (searchKeyword == string.Empty)
// {
// Notes = AllNotes;
// return;
// }
//
// Notes = AllNotes.FindAll(n =>
// {
// var keyword = $"{n.location}/{n.name}";
// return keyword.Contains(searchKeyword, StringComparison.CurrentCultureIgnoreCase);
// });
SearchBar searchBar = (SearchBar)sender;
var searchKeyword = searchBar.Text;

if (AllNotes == null) AllNotes = Notes.ToList();

if (searchKeyword == string.Empty)
{
Notes = new ObservableCollection<Note>(AllNotes);
return;
}

Notes = new ObservableCollection<Note>(AllNotes.FindAll(n =>
{
var keyword = $"{n.location}/{n.name}";
return keyword.Contains(searchKeyword, StringComparison.CurrentCultureIgnoreCase);
}));
}

[RelayCommand]
Expand Down

0 comments on commit 22f1029

Please sign in to comment.