Refactored the event bloc to listen for updates in the media list instead of fetching them once

This commit is contained in:
Mariano Uvalle 2019-04-08 15:09:55 -05:00
parent d4813bdce9
commit acc0b54cfb
2 changed files with 7 additions and 2 deletions

View file

@ -123,7 +123,13 @@ class EventBloc {
/// Fetches the paths of all the images linked to this event.
Future<void> fetchImagesPaths() async {
await _ready;
_imagesPaths.sink.add(_event.media);
_firestore.getEventObservable(_user.id, _event.id).transform(
StreamTransformer<EventModel, List<String>>.fromHandlers(
handleData: (event, sink) {
sink.add(event.media);
},
),
).pipe(_imagesPaths);
}
/// Marks a task as done in the database.

View file

@ -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';