Skip to content

Commit

Permalink
[Binni] Fix. multiple auto save (SankethBK#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
droidbg committed Oct 2, 2023
1 parent deacc99 commit 2324ca2
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/features/notes/presentation/bloc/notes/notes_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,18 @@ class NotesBloc extends Bloc<NotesEvent, NotesState> {

on<UpdateNote>((event, emit) {
// we don't want to update when something is getting saved or deleted
// so we need to process the body afterwards to get current list of assets, and suitably delete removed ones

if (state is NoteInitialState || state is NoteUpdatedState) {
// so we need to process the body afterwards to get current list of assets, and suitably delete removed ones
emit(NoteUpdatedState(
newNote: state.newNote!,
id: state.id,
title: event.title ?? state.title!,
controller: state.controller!,
createdAt: event.createdAt ?? state.createdAt!,
allNoteAssets: event.noteAsset != null
? [...state.allNoteAssets!, event.noteAsset!]
: state.allNoteAssets!,
));
}
emit(NoteUpdatedState(
newNote: state.newNote!,
id: state.id,
title: event.title ?? state.title!,
controller: state.controller!,
createdAt: event.createdAt ?? state.createdAt!,
allNoteAssets: event.noteAsset != null
? [...state.allNoteAssets!, event.noteAsset!]
: state.allNoteAssets!,
));
});

on<SaveNote>((event, emit) async {
Expand Down

0 comments on commit 2324ca2

Please sign in to comment.