Hello
I have my notebooksPage, witch read all my notebooks, but when I navigate to my Notes page, for some reason it read the notebooks again, this is becouse on inheritance
NotebookPageModel
public async virtual void SeletedItemActionAsync() {
if (SelectedNotebook != null) {
NotesPage notesPage = new NotesPage();
Application.Current.Properties["id"] = SelectedNotebook.Id;
await Application.Current.MainPage.Navigation.PushAsync(notesPage, true);
SelectedNotebook = null;
}
}
Here I m passing the selected Notobook selected id to the NotesPage model
NotesPageModel
public class NotesPageModel : NotebooksPageModel {
public string NotebookId { get; set; }
public Note SeletedNote { get; set; }
public Command<Note> DeleteNoteCommand { get; set; }
public Command PageDisappearCommand { get; set; }
public NotesPageModel() {
DeleteNoteCommand = new Command<Note>(DeleteNoteAction);
FabAnimationCommmand = new Command<Frame>(AnimateButtonCommand);
// PageDisappearCommand = new Command(PageDisappearAction);
}
public override async void AppearAction() {
base.AppearAction();
NotebookId = Application.Current.Properties["id"] as string;
Console.WriteLine($"NotebookID {NotebookId}");
FireBaseNotebookNotes = await App.FirebaseServices.ReadAsync(AppConstant.Notes, NotebookId);
}
This method fires every time the page appears, and I can verify I have the ID
ReadAsync
public async Task<ObservableCollection<NotebookNote>> ReadAsync(string ChildName, string NotebookId = "") {
var list = await firebaseClient.Child(ChildName)
.OnceAsync<NotebookNote>();
var collection = new List<NotebookNote>();
foreach (var item in list) {
NotebookNote notebookNote = null;
notebookNote = Convert(ChildName, item);
collection.Add(notebookNote);
}
if (ChildName.Equals(AppConstant.Notes)) {
collection = collection.Where(n => ((Note)n).NotebookId == NotebookId).ToList();
} else {
collection = collection.Where(n => n.UserID == Preferences.Get(AppConstant.UserID, string.Empty)).ToList();
}
FireBaseNotebooks.Clear();
foreach (var element in collection) {
FireBaseNotebooks.Add(element);
}
return FireBaseNotebooks;
}
https://github.com/eduardoagr/DuoNotes