refactor newsfeed and note

This commit is contained in:
Ren Amamiya
2023-03-25 15:26:32 +07:00
parent f1965e1b43
commit f1647fd857
23 changed files with 530 additions and 444 deletions

View File

@@ -1,3 +1,5 @@
import destr from 'destr';
export const tagsToArray = (arr) => {
const newarr = [];
// push item to newarr
@@ -15,3 +17,22 @@ export const pubkeyArray = (arr) => {
});
return newarr;
};
export const getParentID = (arr, fallback) => {
const tags = destr(arr);
let parentID = fallback;
if (tags.length > 0) {
if (tags[0][0] === 'e' || tags[0][2] === 'root' || tags[0][3] === 'root') {
parentID = tags[0][1];
} else {
tags.forEach((tag) => {
if (tag[0] === 'e' && (tag[2] === 'root' || tag[3] === 'root')) {
parentID = tag[1];
}
});
}
}
return parentID;
};