summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-02-19 06:36:50 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-02-19 06:36:50 +0900
commitb23b3e4d2102c274e4e1dd4bdc4ca6cfec42c354 (patch)
tree1df68d528ebb773ebfee04a8cb0a5121a3d0ddb5 /src/misc
parentImprove notification (diff)
downloadsharkey-b23b3e4d2102c274e4e1dd4bdc4ca6cfec42c354.tar.gz
sharkey-b23b3e4d2102c274e4e1dd4bdc4ca6cfec42c354.tar.bz2
sharkey-b23b3e4d2102c274e4e1dd4bdc4ca6cfec42c354.zip
Fix #5984
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/reaction-lib.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/misc/reaction-lib.ts b/src/misc/reaction-lib.ts
index eba57ea303..c525d89385 100644
--- a/src/misc/reaction-lib.ts
+++ b/src/misc/reaction-lib.ts
@@ -20,6 +20,28 @@ export async function getFallbackReaction(): Promise<string> {
return meta.useStarForReactionFallback ? '⭐' : '👍';
}
+export function convertLegacyReactions(reactions: Record<string, number>) {
+ const _reactions = {} as Record<string, number>;
+
+ for (const reaction of Object.keys(reactions)) {
+ if (Object.keys(legacy10).includes(reaction)) {
+ if (_reactions[legacy10[reaction]]) {
+ _reactions[legacy10[reaction]] += reactions[reaction];
+ } else {
+ _reactions[legacy10[reaction]] = reactions[reaction];
+ }
+ } else {
+ if (_reactions[reaction]) {
+ _reactions[reaction] += reactions[reaction];
+ } else {
+ _reactions[reaction] = reactions[reaction];
+ }
+ }
+ }
+
+ return _reactions;
+}
+
export async function toDbReaction(reaction?: string | null): Promise<string> {
if (reaction == null) return await getFallbackReaction();