Compare commits

...

2 Commits

3 changed files with 10 additions and 0 deletions

View File

@ -85,4 +85,7 @@ class Sticker with _$Sticker {
.toList(),
suggests,
);
/// True, if the sticker is backed by an image with MIME type image/*.
bool get isImage => mediaType.startsWith('image/');
}

View File

@ -54,6 +54,7 @@ class AddContactBloc extends Bloc<AddContactEvent, AddContactState> {
}
}
assert(result.conversation != null, 'RequestedConversationEvent must contain a not null conversation');
GetIt.I.get<ConversationBloc>().add(
RequestedConversationEvent(
result.conversation!.jid,

View File

@ -31,6 +31,8 @@ class StickersBloc extends Bloc<StickersEvent, StickersState> {
final map = <StickerKey, Sticker>{};
for (final pack in event.stickerPacks) {
for (final sticker in pack.stickers) {
if (!sticker.isImage) continue;
map[StickerKey(pack.id, sticker.hashKey)] = sticker;
}
}
@ -92,6 +94,8 @@ class StickersBloc extends Bloc<StickersEvent, StickersState> {
if (result is StickerPackImportSuccessEvent) {
final sm = Map<StickerKey, Sticker>.from(state.stickerMap);
for (final sticker in result.stickerPack.stickers) {
if (!sticker.isImage) continue;
sm[StickerKey(result.stickerPack.id, sticker.hashKey)] = sticker;
}
emit(
@ -128,6 +132,8 @@ class StickersBloc extends Bloc<StickersEvent, StickersState> {
Future<void> _onStickerPackAdded(StickerPackAddedEvent event, Emitter<StickersState> emit) async {
final sm = Map<StickerKey, Sticker>.from(state.stickerMap);
for (final sticker in event.stickerPack.stickers) {
if (!sticker.isImage) continue;
sm[StickerKey(event.stickerPack.id, sticker.hashKey)] = sticker;
}