From c144f148163b17a2768a9d9eade01f6f65404532 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 4 Oct 2019 04:37:41 +0200 Subject: [PATCH] Avoid saving hasJournalEntries It can be a simple getter --- lib/appstate.dart | 5 ++++- lib/state_container.dart | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/appstate.dart b/lib/appstate.dart index 20e6bda8..4754aed4 100644 --- a/lib/appstate.dart +++ b/lib/appstate.dart @@ -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 notes = []; diff --git a/lib/state_container.dart b/lib/state_container.dart index 624eec2a..75eba150 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -86,7 +86,6 @@ class StateContainerState extends State { setState(() { appState.isLoadingFromDisk = false; appState.notes = loadedNotes; - appState.hasJournalEntries = loadedNotes.isNotEmpty; getAnalytics().logEvent( name: "notes_loaded", @@ -125,7 +124,6 @@ class StateContainerState extends State { setState(() { appState.isLoadingFromDisk = false; appState.notes = loadedNotes; - appState.hasJournalEntries = loadedNotes.isNotEmpty; }); } catch (err, stack) { setState(() { @@ -198,7 +196,6 @@ class StateContainerState extends State { note.filePath = p.join(noteRepo.notesBasePath, getFileName(note)); } appState.notes.insert(index, note); - appState.hasJournalEntries = true; noteRepo.addNote(note).then((NoteRepoResult _) { _syncNotes(); });