feat: add useEventReactions to system-react

This commit is contained in:
2023-10-16 21:24:54 +01:00
parent 3b427338f4
commit 5e42c5e70c
7 changed files with 83 additions and 76 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@snort/shared",
"version": "1.0.7",
"version": "1.0.8",
"description": "Shared components for Snort",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -193,3 +193,25 @@ export async function fetchNip05Pubkey(name: string, domain: string, timeout = 2
export function removeUndefined<T>(v: Array<T | undefined>) {
return v.filter(a => a != undefined).map(a => unwrap(a));
}
/**
* Reaction types
*/
export const enum Reaction {
Positive = "+",
Negative = "-",
}
/**
* Return normalized reaction content
*/
export function normalizeReaction(content: string) {
switch (content) {
case "-":
return Reaction.Negative;
case "👎":
return Reaction.Negative;
default:
return Reaction.Positive;
}
}