part of '../neon_spreed.dart'; abstract class SpreedBlocEvents { void createRoom( final spreed.RoomType type, final String? roomName, final core.AutocompleteResult? invite, ); } abstract class SpreedBlocStates { BehaviorSubject>> get rooms; BehaviorSubject get unreadCounter; } class SpreedBloc extends InteractiveBloc implements SpreedBlocEvents, SpreedBlocStates { SpreedBloc( this.options, this.account, ) { rooms.listen((final result) { if (result.hasData) { unreadCounter.add( [0, ...result.requireData.map((final room) => room.unreadMessages)].reduce((final a, final b) => a + b), ); } }); unawaited(refresh()); } final SpreedAppSpecificOptions options; final Account account; @override void dispose() { unawaited(rooms.close()); unawaited(unreadCounter.close()); super.dispose(); } @override BehaviorSubject>> rooms = BehaviorSubject(); @override BehaviorSubject unreadCounter = BehaviorSubject(); @override Future refresh() async { await RequestManager.instance.wrapNextcloud( account.id, 'spreed-rooms', rooms, account.client.spreed.room.getRoomsRaw(), (final response) => response.body.ocs.data.toList(), ); } @override void createRoom( final spreed.RoomType type, final String? roomName, final core.AutocompleteResult? invite, ) { wrapAction( () async => account.client.spreed.room.createRoom( roomType: type.value, roomName: roomName ?? '', invite: invite?.id ?? '', source: invite?.source ?? '', ), ); } }