Avoid saving hasJournalEntries

It can be a simple getter
This commit is contained in:
Vishesh Handa
2019-10-04 04:37:41 +02:00
parent 3d8aa2ad70
commit c144f14816
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,10 @@ class AppState {
//
/// This is the directory where all the git repos are stored
String gitBaseDirectory = "";
bool hasJournalEntries = false;
bool get hasJournalEntries {
return notes.isNotEmpty;
}
bool isLoadingFromDisk = false;
List<Note> notes = [];

View File

@ -86,7 +86,6 @@ class StateContainerState extends State<StateContainer> {
setState(() {
appState.isLoadingFromDisk = false;
appState.notes = loadedNotes;
appState.hasJournalEntries = loadedNotes.isNotEmpty;
getAnalytics().logEvent(
name: "notes_loaded",
@ -125,7 +124,6 @@ class StateContainerState extends State<StateContainer> {
setState(() {
appState.isLoadingFromDisk = false;
appState.notes = loadedNotes;
appState.hasJournalEntries = loadedNotes.isNotEmpty;
});
} catch (err, stack) {
setState(() {
@ -198,7 +196,6 @@ class StateContainerState extends State<StateContainer> {
note.filePath = p.join(noteRepo.notesBasePath, getFileName(note));
}
appState.notes.insert(index, note);
appState.hasJournalEntries = true;
noteRepo.addNote(note).then((NoteRepoResult _) {
_syncNotes();
});