refactor newsfeed and note
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user