Browse Source

neon: Fix updating note

pull/34/head
jld3103 2 years ago
parent
commit
7182fe65bc
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 14
      packages/neon/lib/src/apps/notes/blocs/notes.dart
  2. 16
      packages/neon/lib/src/apps/notes/blocs/notes.rxb.g.dart
  3. 4
      packages/neon/lib/src/apps/notes/pages/note.dart
  4. 4
      packages/neon/lib/src/apps/notes/widgets/notes_view.dart

14
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}"',
))!,
),
);

16
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<NotesNote>();
/// Тhe [Subject] where events sink to by calling [updateNote]
final _$updateNoteEvent = PublishSubject<_UpdateNoteEventArgs>();
final _$updateNoteEvent = PublishSubject<NotesNote>();
/// Тhe [Subject] where events sink to by calling [deleteNote]
final _$deleteNoteEvent = PublishSubject<NotesNote>();
@ -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;
}

4
packages/neon/lib/src/apps/notes/pages/note.dart

@ -36,9 +36,9 @@ class _NotesNotePageState extends State<NotesNotePage> {
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,

4
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!,
),
);

Loading…
Cancel
Save