Skip to content

Commit

Permalink
Merge pull request #1611 from nextcloud/refactor/rename-list-subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Feb 18, 2024
2 parents 7d1d52c + e623d8e commit f11d9e4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions packages/neon/neon_notes/lib/src/blocs/notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:neon_framework/blocs.dart';
import 'package:neon_framework/models.dart';
import 'package:neon_framework/utils.dart';
import 'package:neon_notes/src/options.dart';
import 'package:nextcloud/notes.dart' as notes;
import 'package:nextcloud/notes.dart' as $notes;
import 'package:rxdart/rxdart.dart';

sealed class NotesBloc implements InteractiveBloc {
Expand Down Expand Up @@ -36,7 +36,7 @@ sealed class NotesBloc implements InteractiveBloc {

void deleteNote(int id);

BehaviorSubject<Result<BuiltList<notes.Note>>> get notesList;
BehaviorSubject<Result<BuiltList<$notes.Note>>> get notes;

NotesOptions get options;
}
Expand All @@ -55,19 +55,19 @@ class _NotesBloc extends InteractiveBloc implements NotesBloc {

@override
void dispose() {
unawaited(notesList.close());
unawaited(notes.close());
super.dispose();
}

@override
final notesList = BehaviorSubject();
final notes = BehaviorSubject();

@override
Future<void> refresh() async {
await RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'notes-notes',
subject: notesList,
subject: notes,
rawResponse: account.client.notes.getNotesRaw(),
unwrap: (response) => response.body,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NotesCategoriesView extends StatelessWidget {

@override
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: bloc.notesList,
subject: bloc.notes,
builder: (context, notes) => SortBoxBuilder(
sortBox: categoriesSortBox,
sortProperty: bloc.options.categoriesSortPropertyOption,
Expand Down
4 changes: 2 additions & 2 deletions packages/neon/neon_notes/lib/src/widgets/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _NotesCreateNoteDialogState extends State<NotesCreateNoteDialog> {
);

final folderSelector = ResultBuilder.behaviorSubject(
subject: widget.bloc.notesList,
subject: widget.bloc.notes,
builder: (context, notes) {
if (notes.hasError) {
return Center(
Expand Down Expand Up @@ -148,7 +148,7 @@ class _NotesSelectCategoryDialogState extends State<NotesSelectCategoryDialog> {
@override
Widget build(BuildContext context) {
final folderSelector = ResultBuilder.behaviorSubject(
subject: widget.bloc.notesList,
subject: widget.bloc.notes,
builder: (context, notes) {
if (notes.hasError) {
return Center(
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_notes/lib/src/widgets/notes_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NotesView extends StatelessWidget {

@override
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: bloc.notesList,
subject: bloc.notes,
builder: (context, notesList) => SortBoxBuilder(
sortBox: notesSortBox,
presort: const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:neon_framework/blocs.dart';
import 'package:neon_framework/models.dart';
import 'package:neon_framework/utils.dart';
import 'package:neon_notifications/src/options.dart';
import 'package:nextcloud/notifications.dart' as notifications;
import 'package:nextcloud/notifications.dart' as $notifications;
import 'package:rxdart/rxdart.dart';

sealed class NotificationsBloc implements NotificationsBlocInterface, InteractiveBloc {
Expand All @@ -22,7 +22,7 @@ sealed class NotificationsBloc implements NotificationsBlocInterface, Interactiv

void deleteAllNotifications();

BehaviorSubject<Result<BuiltList<notifications.Notification>>> get notificationsList;
BehaviorSubject<Result<BuiltList<$notifications.Notification>>> get notifications;

BehaviorSubject<int> get unreadCounter;
}
Expand All @@ -32,7 +32,7 @@ class _NotificationsBloc extends InteractiveBloc implements NotificationsBlocInt
this.options,
this.account,
) {
notificationsList.listen((result) {
notifications.listen((result) {
if (result.hasData) {
unreadCounter.add(result.requireData.length);
}
Expand All @@ -49,13 +49,13 @@ class _NotificationsBloc extends InteractiveBloc implements NotificationsBlocInt
@override
void dispose() {
timer.cancel();
unawaited(notificationsList.close());
unawaited(notifications.close());
unawaited(unreadCounter.close());
super.dispose();
}

@override
final notificationsList = BehaviorSubject();
final notifications = BehaviorSubject();

@override
final unreadCounter = BehaviorSubject();
Expand All @@ -65,7 +65,7 @@ class _NotificationsBloc extends InteractiveBloc implements NotificationsBlocInt
await RequestManager.instance.wrapNextcloud(
account: account,
cacheKey: 'notifications-notifications',
subject: notificationsList,
subject: notifications,
rawResponse: account.client.notifications.endpoint.listNotificationsRaw(),
unwrap: (response) => response.body.ocs.data,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_notifications/lib/src/pages/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {

@override
Widget build(BuildContext context) => ResultBuilder.behaviorSubject(
subject: bloc.notificationsList,
subject: bloc.notifications,
builder: (context, notifications) => Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButton: StreamBuilder(
Expand Down

0 comments on commit f11d9e4

Please sign in to comment.