Skip to content

Commit 6d15de7

Browse files
authored
fix some channels missing 7tv emotes (#444)
* remove bang operator * handle 7tv emotes that are being processed
1 parent 19e6625 commit 6d15de7

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

lib/apis/seventv_api.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class SevenTVApi {
4242
emoteSetId,
4343
emotes
4444
.map((emote) => Emote.from7TV(emote, EmoteType.sevenTVChannel))
45+
.where((emote) => emote.url.isNotEmpty)
4546
.toList()
4647
);
4748
} else {

lib/models/emotes.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:collection/collection.dart';
12
import 'package:frosty/constants.dart';
23
import 'package:json_annotation/json_annotation.dart';
34

@@ -127,7 +128,7 @@ class EmoteFFZ {
127128
class Emote7TV {
128129
final String id;
129130
final String name;
130-
final Emote7TVData? data;
131+
final Emote7TVData data;
131132

132133
const Emote7TV(
133134
this.id,
@@ -267,10 +268,10 @@ class Emote {
267268
factory Emote.from7TV(Emote7TV emote, EmoteType type) {
268269
final emoteData = emote.data;
269270

270-
final url = emoteData!.host.url;
271+
final url = emoteData.host.url;
271272

272-
// Flutter doesn't support AVIF yet.
273-
final file = emoteData.host.files.lastWhere(
273+
// TODO: Remove if/when Flutter natively supports AVIF.
274+
final file = emoteData.host.files.lastWhereOrNull(
274275
(file) => file.format != 'AVIF',
275276
);
276277

@@ -280,10 +281,10 @@ class Emote {
280281
return Emote(
281282
name: emote.name,
282283
realName: emote.name != emoteData.name ? emoteData.name : null,
283-
width: emoteData.host.files.first.width,
284-
height: emoteData.host.files.first.height,
284+
width: emoteData.host.files.firstOrNull?.width,
285+
height: emoteData.host.files.firstOrNull?.height,
285286
zeroWidth: isZeroWidth,
286-
url: 'https:$url/${file.name}',
287+
url: file != null ? 'https:$url/${file.name}' : '',
287288
type: type,
288289
ownerDisplayName: emoteData.owner?.displayName,
289290
ownerUsername: emoteData.owner?.username,

lib/models/emotes.g.dart

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/events.g.dart

Lines changed: 6 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)