mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
Avoid saving hasJournalEntries
It can be a simple getter
This commit is contained in:
@ -22,7 +22,10 @@ class AppState {
|
|||||||
//
|
//
|
||||||
/// This is the directory where all the git repos are stored
|
/// This is the directory where all the git repos are stored
|
||||||
String gitBaseDirectory = "";
|
String gitBaseDirectory = "";
|
||||||
bool hasJournalEntries = false;
|
|
||||||
|
bool get hasJournalEntries {
|
||||||
|
return notes.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
bool isLoadingFromDisk = false;
|
bool isLoadingFromDisk = false;
|
||||||
List<Note> notes = [];
|
List<Note> notes = [];
|
||||||
|
@ -86,7 +86,6 @@ class StateContainerState extends State<StateContainer> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
appState.isLoadingFromDisk = false;
|
appState.isLoadingFromDisk = false;
|
||||||
appState.notes = loadedNotes;
|
appState.notes = loadedNotes;
|
||||||
appState.hasJournalEntries = loadedNotes.isNotEmpty;
|
|
||||||
|
|
||||||
getAnalytics().logEvent(
|
getAnalytics().logEvent(
|
||||||
name: "notes_loaded",
|
name: "notes_loaded",
|
||||||
@ -125,7 +124,6 @@ class StateContainerState extends State<StateContainer> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
appState.isLoadingFromDisk = false;
|
appState.isLoadingFromDisk = false;
|
||||||
appState.notes = loadedNotes;
|
appState.notes = loadedNotes;
|
||||||
appState.hasJournalEntries = loadedNotes.isNotEmpty;
|
|
||||||
});
|
});
|
||||||
} catch (err, stack) {
|
} catch (err, stack) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -198,7 +196,6 @@ class StateContainerState extends State<StateContainer> {
|
|||||||
note.filePath = p.join(noteRepo.notesBasePath, getFileName(note));
|
note.filePath = p.join(noteRepo.notesBasePath, getFileName(note));
|
||||||
}
|
}
|
||||||
appState.notes.insert(index, note);
|
appState.notes.insert(index, note);
|
||||||
appState.hasJournalEntries = true;
|
|
||||||
noteRepo.addNote(note).then((NoteRepoResult _) {
|
noteRepo.addNote(note).then((NoteRepoResult _) {
|
||||||
_syncNotes();
|
_syncNotes();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user