chore: update emote stuff

This commit is contained in:
Sorunome 2020-09-24 15:57:58 +02:00
parent 5019ebfeb5
commit b6754fbc46
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 20 additions and 10 deletions

View File

@ -446,7 +446,7 @@ class Room {
final allMxcs = <String>{}; // for easy dedupint final allMxcs = <String>{}; // for easy dedupint
final addEmotePack = (String packName, Map<String, dynamic> content, final addEmotePack = (String packName, Map<String, dynamic> content,
[String packNameOverride]) { [String packNameOverride]) {
if (!(content['short'] is Map)) { if (!(content['emoticons'] is Map) && !(content['short'] is Map)) {
return; return;
} }
if (content['pack'] is Map && content['pack']['name'] is String) { if (content['pack'] is Map && content['pack']['name'] is String) {
@ -459,13 +459,26 @@ class Room {
if (!packs.containsKey(packName)) { if (!packs.containsKey(packName)) {
packs[packName] = <String, String>{}; packs[packName] = <String, String>{};
} }
content['short'].forEach((key, value) { if (content['emoticons'] is Map) {
if (key is String && value is String && value.startsWith('mxc://')) { content['emoticons'].forEach((key, value) {
if (allMxcs.add(value)) { if (key is String &&
packs[packName][key] = value; value is Map &&
value['url'] is String &&
value['url'].startsWith('mxc://')) {
if (allMxcs.add(value['url'])) {
packs[packName][key] = value['url'];
}
} }
} });
}); } else {
content['short'].forEach((key, value) {
if (key is String && value is String && value.startsWith('mxc://')) {
if (allMxcs.add(value)) {
packs[packName][key] = value;
}
}
});
}
}; };
// first add all the user emotes // first add all the user emotes
final userEmotes = client.accountData['im.ponies.user_emotes']; final userEmotes = client.accountData['im.ponies.user_emotes'];
@ -477,9 +490,6 @@ class Room {
if (emoteRooms != null && emoteRooms.content['rooms'] is Map) { if (emoteRooms != null && emoteRooms.content['rooms'] is Map) {
for (final roomEntry in emoteRooms.content['rooms'].entries) { for (final roomEntry in emoteRooms.content['rooms'].entries) {
final roomId = roomEntry.key; final roomId = roomEntry.key;
if (roomId == id) {
continue;
}
final room = client.getRoomById(roomId); final room = client.getRoomById(roomId);
if (room != null && roomEntry.value is Map) { if (room != null && roomEntry.value is Map) {
for (final stateKeyEntry in roomEntry.value.entries) { for (final stateKeyEntry in roomEntry.value.entries) {