From 238bb0ed46e71ca1148139cafe03c1d9c5a6eb65 Mon Sep 17 00:00:00 2001 From: Max Krieger Date: Fri, 12 Apr 2024 01:37:50 -0700 Subject: [PATCH] chore: remove unnecessary selectors --- lib/views/notes_view.dart | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/views/notes_view.dart b/lib/views/notes_view.dart index d1f7ec7..a5f3b02 100644 --- a/lib/views/notes_view.dart +++ b/lib/views/notes_view.dart @@ -5,6 +5,7 @@ import 'package:provider/provider.dart'; import 'package:scroll_to_index/scroll_to_index.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:timeago_flutter/timeago_flutter.dart'; +import 'package:voice_outliner/data/outline.dart'; import 'package:voice_outliner/repositories/db_repository.dart'; import 'package:voice_outliner/state/notes_state.dart'; import 'package:voice_outliner/state/outline_state.dart'; @@ -277,21 +278,10 @@ class _NotesViewState extends State<_NotesView> { Widget buildChild(BuildContext context) { final outlineId = widget.args.outlineId; - final currentOutlineName = context.select((value) => - value.outlines - .firstWhere((element) => element.id == outlineId, - orElse: () => defaultOutline) - .name); - final currentOutlineEmoji = context.select((value) => - value.outlines - .firstWhere((element) => element.id == outlineId, - orElse: () => defaultOutline) - .emoji); - final currentOutlineArchived = context.select( - (value) => value.outlines - .firstWhere((element) => element.id == outlineId, - orElse: () => defaultOutline) - .archived); + final currentOutline = context.select((value) => + value.outlines.firstWhere((element) => element.id == outlineId, + orElse: () => defaultOutline)); + final noteCount = context.select((value) => value.notes.length); final scrollController = context.select( @@ -313,7 +303,7 @@ class _NotesViewState extends State<_NotesView> { onTap: () => _handleMenu("rename"), borderRadius: const BorderRadius.all(Radius.circular(5.0)), child: Text( - "$currentOutlineEmoji $currentOutlineName", + "${currentOutline.emoji} ${currentOutline.name}", overflow: TextOverflow.fade, )), ), @@ -322,7 +312,7 @@ class _NotesViewState extends State<_NotesView> { onPressed: _goToOutlines, icon: const Icon(Icons.chevron_left)), actions: [ - if (currentOutlineArchived) + if (currentOutline.archived) IconButton( tooltip: "currently archived - unarchive?", icon: const Icon(Icons.unarchive), @@ -370,7 +360,7 @@ class _NotesViewState extends State<_NotesView> { Opacity( opacity: 0.5, child: Text( - currentOutlineEmoji, + currentOutline.emoji, style: const TextStyle(fontSize: 80.0), textAlign: TextAlign.center, )),