From acc0b54cfba7b8a0b49a193d197f464546523913 Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Mon, 8 Apr 2019 15:09:55 -0500 Subject: [PATCH] Refactored the event bloc to listen for updates in the media list instead of fetching them once --- lib/src/blocs/event_bloc.dart | 8 +++++++- lib/src/screens/event_screen.dart | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/src/blocs/event_bloc.dart b/lib/src/blocs/event_bloc.dart index 69cd55c..2779472 100644 --- a/lib/src/blocs/event_bloc.dart +++ b/lib/src/blocs/event_bloc.dart @@ -123,7 +123,13 @@ class EventBloc { /// Fetches the paths of all the images linked to this event. Future fetchImagesPaths() async { await _ready; - _imagesPaths.sink.add(_event.media); + _firestore.getEventObservable(_user.id, _event.id).transform( + StreamTransformer>.fromHandlers( + handleData: (event, sink) { + sink.add(event.media); + }, + ), + ).pipe(_imagesPaths); } /// Marks a task as done in the database. diff --git a/lib/src/screens/event_screen.dart b/lib/src/screens/event_screen.dart index d6a4058..97b12e1 100644 --- a/lib/src/screens/event_screen.dart +++ b/lib/src/screens/event_screen.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../utils.dart' show getImageThumbnailPath; import '../blocs/event_bloc.dart';