fixed two issues - gStore and getParent

initialized gStore for --request case

And, fixed getParent for event, since otherwise it would return wrong parent. Now it would result in a dummy parent, as it should.
This commit is contained in:
Vishal 2022-09-24 13:51:14 +05:30
parent b30047baa9
commit a32e68affd
2 changed files with 6 additions and 0 deletions

View File

@ -238,6 +238,7 @@ Future<void> main(List<String> arguments) async {
clearEvents();
if( gDebug > 0) stdout.write("Total events of kind 1 in created tree: ${node.count()} events\n");
gStore = node;
mainMenuUi(node);
});
return;

View File

@ -65,6 +65,7 @@ class EventData {
bool isHidden; // hidden by sending a reaction kind 7 event to this event, by the logged in user
bool isDeleted; // deleted by kind 5 event
// returns the immediate kind 1 parent
String getParent(Map<String, Tree> allEventsMap) {
if( eTags.isNotEmpty) {
for( int i = eTags.length - 1; i >= 0; i--) {
@ -74,6 +75,10 @@ class EventData {
if( parentId != null) {
return parentId;
}
} else {
// if first e tag ( from end, which is the immediate parent) does not exist in the store, then return empty.
// This has the drawback that the child comment would get a dummy parent, and would get out of the thread TODO fix that later
return "";
}
}
}