diff --git a/packages/neon/lib/src/apps/notes/blocs/notes.dart b/packages/neon/lib/src/apps/notes/blocs/notes.dart index 939e39dc..5daac4f4 100644 --- a/packages/neon/lib/src/apps/notes/blocs/notes.dart +++ b/packages/neon/lib/src/apps/notes/blocs/notes.dart @@ -12,11 +12,7 @@ abstract class NotesBlocEvents { void createNote(final NotesNote note); - void updateNote( - final int id, - final String etag, - final NotesNote note, - ); + void updateNote(final NotesNote note); void deleteNote(final NotesNote note); } @@ -42,13 +38,13 @@ class NotesBloc extends $NotesBloc { _wrapAction(() async => client.notes.createNote(note)); }); - _$updateNoteEvent.listen((final event) { + _$updateNoteEvent.listen((final note) { _wrapAction( () async => _noteUpdateController.add( (await client.notes.updateNote( - event.id, - event.note, - ifMatch: '"${event.etag}"', + note.id!, + note, + ifMatch: '"${note.etag}"', ))!, ), ); diff --git a/packages/neon/lib/src/apps/notes/blocs/notes.rxb.g.dart b/packages/neon/lib/src/apps/notes/blocs/notes.rxb.g.dart index d36dc691..3726797a 100644 --- a/packages/neon/lib/src/apps/notes/blocs/notes.rxb.g.dart +++ b/packages/neon/lib/src/apps/notes/blocs/notes.rxb.g.dart @@ -25,7 +25,7 @@ abstract class $NotesBloc extends RxBlocBase implements NotesBlocEvents, NotesBl final _$createNoteEvent = PublishSubject(); /// Тhe [Subject] where events sink to by calling [updateNote] - final _$updateNoteEvent = PublishSubject<_UpdateNoteEventArgs>(); + final _$updateNoteEvent = PublishSubject(); /// Тhe [Subject] where events sink to by calling [deleteNote] final _$deleteNoteEvent = PublishSubject(); @@ -46,7 +46,7 @@ abstract class $NotesBloc extends RxBlocBase implements NotesBlocEvents, NotesBl void createNote(NotesNote note) => _$createNoteEvent.add(note); @override - void updateNote(int id, String etag, NotesNote note) => _$updateNoteEvent.add(_UpdateNoteEventArgs(id, etag, note)); + void updateNote(NotesNote note) => _$updateNoteEvent.add(note); @override void deleteNote(NotesNote note) => _$deleteNoteEvent.add(note); @@ -82,15 +82,3 @@ abstract class $NotesBloc extends RxBlocBase implements NotesBlocEvents, NotesBl super.dispose(); } } - -/// Helps providing the arguments in the [Subject.add] for -/// [NotesBlocEvents.updateNote] event -class _UpdateNoteEventArgs { - const _UpdateNoteEventArgs(this.id, this.etag, this.note); - - final int id; - - final String etag; - - final NotesNote note; -} diff --git a/packages/neon/lib/src/apps/notes/pages/note.dart b/packages/neon/lib/src/apps/notes/pages/note.dart index aba799f4..53786a13 100644 --- a/packages/neon/lib/src/apps/notes/pages/note.dart +++ b/packages/neon/lib/src/apps/notes/pages/note.dart @@ -36,9 +36,9 @@ class _NotesNotePageState extends State { if (updatedTitle != null || updatedCategory != null || updatedContent != null) { widget.bloc.updateNote( - _note.id!, - _note.etag!, NotesNote( + id: _note.id!, + etag: _note.etag!, title: updatedTitle, category: updatedCategory, content: updatedContent, diff --git a/packages/neon/lib/src/apps/notes/widgets/notes_view.dart b/packages/neon/lib/src/apps/notes/widgets/notes_view.dart index fb118a5d..2aa2031b 100644 --- a/packages/neon/lib/src/apps/notes/widgets/notes_view.dart +++ b/packages/neon/lib/src/apps/notes/widgets/notes_view.dart @@ -132,9 +132,9 @@ class NotesView extends StatelessWidget { ), onPressed: () { bloc.updateNote( - note.id!, - note.etag!, NotesNote( + id: note.id!, + etag: note.etag!, favorite: !note.favorite!, ), );