mirror of
https://github.com/tommyxchow/frosty.git
synced 2025-05-21 00:16:33 +08:00
Fix 7TV emotes not using custom names (#291)
* Fix 7TV emotes not using custom set names * Show real name in emote details
This commit is contained in:
@ -107,20 +107,36 @@ class EmoteFFZ {
|
||||
|
||||
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
||||
class Emote7TV {
|
||||
final String id;
|
||||
final String name;
|
||||
final Emote7TVData data;
|
||||
|
||||
const Emote7TV(
|
||||
this.id,
|
||||
this.name,
|
||||
this.data,
|
||||
);
|
||||
|
||||
factory Emote7TV.fromJson(Map<String, dynamic> json) =>
|
||||
_$Emote7TVFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
||||
class Emote7TVData {
|
||||
final String id;
|
||||
final String name;
|
||||
final List<String>? tags;
|
||||
final Emote7TVHost host;
|
||||
|
||||
const Emote7TV(
|
||||
const Emote7TVData(
|
||||
this.id,
|
||||
this.name,
|
||||
this.tags,
|
||||
this.host,
|
||||
);
|
||||
|
||||
factory Emote7TV.fromJson(Map<String, dynamic> json) =>
|
||||
_$Emote7TVFromJson(json);
|
||||
factory Emote7TVData.fromJson(Map<String, dynamic> json) =>
|
||||
_$Emote7TVDataFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
||||
@ -159,6 +175,7 @@ class Emote7TVFile {
|
||||
@JsonSerializable()
|
||||
class Emote {
|
||||
final String name;
|
||||
final String? realName;
|
||||
final int? width;
|
||||
final int? height;
|
||||
final bool zeroWidth;
|
||||
@ -168,6 +185,7 @@ class Emote {
|
||||
|
||||
const Emote({
|
||||
required this.name,
|
||||
this.realName,
|
||||
this.width,
|
||||
this.height,
|
||||
required this.zeroWidth,
|
||||
@ -202,17 +220,18 @@ class Emote {
|
||||
);
|
||||
|
||||
factory Emote.from7TV(Emote7TV emote, EmoteType type) {
|
||||
final url = emote.host.url;
|
||||
final url = emote.data.host.url;
|
||||
// Flutter doesn't support AVIF yet.
|
||||
final file = emote.host.files.reversed.firstWhere(
|
||||
final file = emote.data.host.files.reversed.firstWhere(
|
||||
(file) => file.format != 'AVIF' && file.name.contains('4x'),
|
||||
);
|
||||
|
||||
return Emote(
|
||||
name: emote.name,
|
||||
width: emote.host.files.first.width,
|
||||
height: emote.host.files.first.height,
|
||||
zeroWidth: emote.tags?.contains('zerowidth') ?? false,
|
||||
realName: emote.name != emote.data.name ? emote.data.name : null,
|
||||
width: emote.data.host.files.first.width,
|
||||
height: emote.data.host.files.first.height,
|
||||
zeroWidth: emote.data.tags?.contains('zerowidth') ?? false,
|
||||
url: 'https:$url/${file.name}',
|
||||
type: type,
|
||||
);
|
||||
|
Reference in New Issue
Block a user