fix some channels missing 7tv emotes (#444)

* remove bang operator

* handle 7tv emotes that are being processed
This commit is contained in:
Tommy Chow 2025-05-25 19:07:57 -07:00 • committed by GitHub
parent 19e66255be
commit 6d15de707a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 25 deletions

View file

@ -42,6 +42,7 @@ class SevenTVApi {
emoteSetId,
emotes
.map((emote) => Emote.from7TV(emote, EmoteType.sevenTVChannel))
.where((emote) => emote.url.isNotEmpty)
.toList()
);
} else {

View file

@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:frosty/constants.dart';
import 'package:json_annotation/json_annotation.dart';
@ -127,7 +128,7 @@ class EmoteFFZ {
class Emote7TV {
final String id;
final String name;
final Emote7TVData? data;
final Emote7TVData data;
const Emote7TV(
this.id,
@ -267,10 +268,10 @@ class Emote {
factory Emote.from7TV(Emote7TV emote, EmoteType type) {
final emoteData = emote.data;
final url = emoteData!.host.url;
final url = emoteData.host.url;
// Flutter doesn't support AVIF yet.
final file = emoteData.host.files.lastWhere(
// TODO: Remove if/when Flutter natively supports AVIF.
final file = emoteData.host.files.lastWhereOrNull(
(file) => file.format != 'AVIF',
);
@ -280,10 +281,10 @@ class Emote {
return Emote(
name: emote.name,
realName: emote.name != emoteData.name ? emoteData.name : null,
width: emoteData.host.files.first.width,
height: emoteData.host.files.first.height,
width: emoteData.host.files.firstOrNull?.width,
height: emoteData.host.files.firstOrNull?.height,
zeroWidth: isZeroWidth,
url: 'https:$url/${file.name}',
url: file != null ? 'https:$url/${file.name}' : '',
type: type,
ownerDisplayName: emoteData.owner?.displayName,
ownerUsername: emoteData.owner?.username,

View file

@ -63,9 +63,7 @@ EmoteFFZ _$EmoteFFZFromJson(Map<String, dynamic> json) => EmoteFFZ(
Emote7TV _$Emote7TVFromJson(Map<String, dynamic> json) => Emote7TV(
json['id'] as String,
json['name'] as String,
json['data'] == null
? null
: Emote7TVData.fromJson(json['data'] as Map<String, dynamic>),
Emote7TVData.fromJson(json['data'] as Map<String, dynamic>),
);
Owner7TV _$Owner7TVFromJson(Map<String, dynamic> json) => Owner7TV(

View file

@ -12,21 +12,12 @@ SevenTVEvent _$SevenTVEventFromJson(Map<String, dynamic> json) => SevenTVEvent(
d: SevenTVEventData.fromJson(json['d'] as Map<String, dynamic>),
);
Map<String, dynamic> _$SevenTVEventToJson(SevenTVEvent instance) {
final val = <String, dynamic>{
'op': instance.op,
};
void writeNotNull(String key, dynamic value) {
if (value != null) {
val[key] = value;
}
}
writeNotNull('t', instance.t);
val['d'] = instance.d;
return val;
}
Map<String, dynamic> _$SevenTVEventToJson(SevenTVEvent instance) =>
<String, dynamic>{
'op': instance.op,
if (instance.t case final value?) 't': value,
'd': instance.d,
};
SevenTVEventData _$SevenTVEventDataFromJson(Map<String, dynamic> json) =>
SevenTVEventData(