Revert "emoji_reactions"

This reverts commit 0c9b10f307.
This commit is contained in:
cutestnekoaqua 2023-03-17 10:50:39 +01:00
parent a53b70b429
commit fb020ade7b
No known key found for this signature in database
GPG key ID: 6BF0964A5069C1E0
3 changed files with 9 additions and 27 deletions

View file

@ -6,7 +6,5 @@ namespace Entity {
me: boolean
name: string
accounts?: Array<Account>
url: string
static_url: string
}
}

View file

@ -257,44 +257,31 @@ namespace MisskeyAPI {
application: null,
language: null,
pinned: null,
emoji_reactions: mapReactions(host, n.reactions, n.myReaction || '', n.reactionEmojis || {}),
emoji_reactions: mapReactions(n.reactions, n.myReaction),
bookmarked: false,
quote: n.renote && n.text ? note(n.renote, host) : null
}
}
export const mapReactions = (host: string, r: { [key: string]: number }, myReaction: string, emojiData: MisskeyEntity.Emoji[] | MisskeyEntity.EmojiKeyValue): Array<MegalodonEntity.Reaction> => {
if (isEmojiArr(emojiData)) {
return emojiData.map((e) => {return {
count: 0, me: false, name: e.name, url: e.url, static_url: e.url
}})
}
export const mapReactions = (r: { [key: string]: number }, myReaction?: string): Array<MegalodonEntity.Reaction> => {
return Object.keys(r).map(key => {
if (myReaction && key === myReaction) {
return {
count: r[key],
me: true,
name: key,
url: emojiData[key] || `https://${host}/${key.replace(/[:@.]/g, '')}.webp`,
static_url: emojiData[key] || `https://${host}/${key.replace(/[:@.]/g, '')}.webp`
name: key
}
}
return {
count: r[key],
me: false,
name: key,
url: emojiData[key] || `https://${host}/${key.replace(/[:@.]/g, '')}.webp`,
static_url: emojiData[key] || `https://${host}/${key.replace(/[:@.]/g, '')}.webp`
name: key
}
})
}
export const reactions = (r: Array<Entity.Reaction>, host: string, emojiData: MisskeyEntity.Emoji[] | MisskeyEntity.EmojiKeyValue): Array<MegalodonEntity.Reaction> => {
export const reactions = (r: Array<Entity.Reaction>): Array<MegalodonEntity.Reaction> => {
const result: Array<MegalodonEntity.Reaction> = []
if (isEmojiArr(emojiData)) {
return emojiData.map((e) => {return {
count: 0, me: false, name: e.name, url: e.url, static_url: e.url
}})
}
for (const e of r) {
const i = result.findIndex(res => res.name === e.type)
if (i >= 0) {
@ -303,9 +290,7 @@ namespace MisskeyAPI {
result.push({
count: 1,
me: false,
name: e.type,
url: emojiData[e.type] || `https://${host}/${e.type.replace(/[:@.]/g, '')}.webp`,
static_url: emojiData[e.type] || `https://${host}/${e.type.replace(/[:@.]/g, '')}.webp`
name: e.type
})
}
}

View file

@ -15,7 +15,7 @@ namespace MisskeyEntity {
renoteCount: number
repliesCount: number
reactions: { [key: string]: number }
emojis: Array<Emoji> | EmojiKeyValue
emojis: Array<Emoji>
fileIds: Array<string>
files: Array<File>
replyId: string | null
@ -27,7 +27,6 @@ namespace MisskeyEntity {
tags?: Array<string>
poll?: Poll
mentions?: Array<string>
myReaction?: string,
reactionEmojis?: EmojiKeyValue
myReaction?: string
}
}