use swr for note fetcher

This commit is contained in:
Ren Amamiya
2023-04-27 08:57:41 +07:00
parent 38c6b2c76d
commit 8cadb7467f
7 changed files with 204 additions and 312 deletions

View File

@@ -50,6 +50,26 @@ export const getParentID = (arr: string[], fallback: string) => {
return parentID;
};
// get parent id from event tags
export const getQuoteID = (arr: string[]) => {
const tags = destr(arr);
let quoteID = null;
if (tags.length > 0) {
if (tags[0][0] === 'e') {
quoteID = tags[0][1];
} else {
tags.forEach((tag) => {
if (tag[0] === 'e') {
quoteID = tag[1];
}
});
}
}
return quoteID;
};
// sort messages by timestamp
export const sortMessages = (arr: any) => {
arr.sort((a, b) => {