mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-08 22:23:08 +02:00
fix: favourites on megalodon
This commit is contained in:
parent
84fcf9efc7
commit
b2d367faed
2 changed files with 10 additions and 4 deletions
|
@ -265,7 +265,7 @@ namespace MisskeyAPI {
|
||||||
url: n.url ? n.url : host ? `https://${host}/notes/${n.id}` : '',
|
url: n.url ? n.url : host ? `https://${host}/notes/${n.id}` : '',
|
||||||
account: user(n.user, n.user.host ? n.user.host : host ? host : null),
|
account: user(n.user, n.user.host ? n.user.host : host ? host : null),
|
||||||
in_reply_to_id: n.replyId,
|
in_reply_to_id: n.replyId,
|
||||||
in_reply_to_account_id: null,
|
in_reply_to_account_id: n.reply?.userId ?? null,
|
||||||
reblog: n.renote ? note(n.renote, n.user.host ? n.user.host : host ? host : null) : null,
|
reblog: n.renote ? note(n.renote, n.user.host ? n.user.host : host ? host : null) : null,
|
||||||
content: n.text
|
content: n.text
|
||||||
? n.text
|
? n.text
|
||||||
|
@ -282,9 +282,9 @@ namespace MisskeyAPI {
|
||||||
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
|
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
|
||||||
replies_count: n.repliesCount,
|
replies_count: n.repliesCount,
|
||||||
reblogs_count: n.renoteCount,
|
reblogs_count: n.renoteCount,
|
||||||
favourites_count: 0,
|
favourites_count: getTotalReactions(n.reactions),
|
||||||
reblogged: false,
|
reblogged: false,
|
||||||
favourited: false,
|
favourited: !!n.myReaction,
|
||||||
muted: false,
|
muted: false,
|
||||||
sensitive: Array.isArray(n.files) ? n.files.some(f => f.isSensitive) : false,
|
sensitive: Array.isArray(n.files) ? n.files.some(f => f.isSensitive) : false,
|
||||||
spoiler_text: n.cw ? n.cw : '',
|
spoiler_text: n.cw ? n.cw : '',
|
||||||
|
@ -313,6 +313,12 @@ namespace MisskeyAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getTotalReactions = (r: { [key: string]: number }): number => {
|
||||||
|
return Object.values(r).length > 0 ? Object.values(r).reduce(
|
||||||
|
(previousValue, currentValue) => previousValue + currentValue,
|
||||||
|
) : 0;
|
||||||
|
};
|
||||||
|
|
||||||
export const mapReactions = (r: { [key: string]: number }, myReaction?: string): Array<MegalodonEntity.Reaction> => {
|
export const mapReactions = (r: { [key: string]: number }, myReaction?: string): Array<MegalodonEntity.Reaction> => {
|
||||||
return Object.keys(r).map(key => {
|
return Object.keys(r).map(key => {
|
||||||
if (myReaction && key === myReaction) {
|
if (myReaction && key === myReaction) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"lib": ["es6", "dom"], /* Specify library files to be included in the compilation. */
|
"lib": ["es2021", "dom"], /* Specify library files to be included in the compilation. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
|
|
Loading…
Reference in a new issue