Merge pull request #9 from vishalxl/main

from main to patch 2
This commit is contained in:
Vishal 2022-08-30 15:18:33 +05:30 committed by GitHub
commit 02fea46089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 13 deletions

View File

@ -90,6 +90,7 @@ Future<void> main(List<String> arguments) async {
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
} on StdoutException catch (e) {
print("Cannot find terminal size. Left aligning by default.");
if( gDebug > 0) log.info("${e.message}");
gNumLeftMarginSpaces = 0;
}
// undo above if left option is given

View File

@ -190,7 +190,6 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
// if contact list was found, get user's feed, and keep the contact list for later use
String authorName = gKindONames[pubkey.first]?.name??"";
List<String> contactList = [];
printUnderlined("\nProfile for User");
print("\nName : $authorName ( ${pubkey.first} ).");
@ -324,10 +323,12 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
gNumLastDays = int.parse(newNumDays);
print("Changed number of days printed to $gNumLastDays");
} on FormatException catch (e) {
print("Invalid input. Kindly try again.");
print("Invalid input. Kindly try again.");
if( gDebug > 0) print(" ${e.message}");
continue;
} on Exception catch (e) {
print("Invalid input. Kindly try again.");
print("Invalid input. Kindly try again.");
if( gDebug > 0) print(" ${e}");
continue;
}
@ -453,6 +454,8 @@ Future<void> mainMenuUi(Tree node, var contactList) async {
}
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
} on StdoutException catch (e) {
print("Terminal information not available");
if( gDebug>0) print("${e.message}");
gNumLeftMarginSpaces = 0;
}
}

View File

@ -313,7 +313,7 @@ class EventData {
try {
translator
.translate(content, to: 'en')
.catchError( (error, stackTrace) => null )
//.catchError( (error, stackTrace) => null )
.then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("Google translate returned successfully for one call.")}
);
} on Exception catch(err) {
@ -344,9 +344,7 @@ class EventData {
int n = 4;
String maxN(String v) => v.length > n? v.substring(0,n) : v.substring(0, v.length);
void printInColor(String s, String commentColor) => stdout.supportsAnsiEscapes ?stdout.write("$commentColor$s$colorEndMarker"):stdout.write(s);
DateTime dTime = DateTime.fromMillisecondsSinceEpoch(createdAt *1000);
// TODO do it in one call
final df1 = DateFormat('hh:mm a');
final df2 = DateFormat(DateFormat.YEAR_ABBR_MONTH_DAY);
@ -449,6 +447,9 @@ class Event {
}
return Event(json[0] as String, json[1] as String, EventData.fromJson(json[2]), [relay], d );
} on Exception catch(e) {
if( gDebug> 0) {
print("Could not create event. returning dummy event. $e");
}
return Event("","",EventData("non","", 0, 0, "", [], [], [], [[]], {}), [relay], "[json]");
}
}
@ -539,8 +540,9 @@ Set<Event> readEventsFromFile(String filename) {
Event e = Event.fromJson(lines[i], "");
events.add(e);
}
} on Exception catch(err) {
} on Exception catch(e) {
print("cannot open file $gEventsFilename");
print("Could not open file. error = $e");
}
return events;

View File

@ -90,7 +90,6 @@ class Tree {
rooms[chatRoomId]?.name = json['name'];
}
} else {
List<String> temp = [];
String roomName = "", roomAbout = "";
if( json.containsKey('name') ) {
roomName = json['name'];
@ -104,7 +103,7 @@ class Tree {
//if( gDebug > 0) print("Added new chat room $chatRoomId with name ${json['name']} .");
}
} on Exception catch(e) {
if( gDebug > 0) print("In From Event. Event type 40. Json Decode error for event id ${value.e.eventData.id}");
if( gDebug > 0) print("In From Event. Event type 40. Json Decode error for event id ${value.e.eventData.id}. error = $e");
}
}
@ -364,7 +363,7 @@ class Tree {
int numPrinted = 0;
// for the top most tree, create a smaller list which only has recent trees
List<Tree> latestTrees = []; // TODO
//List<Tree> latestTrees = []; // TODO
if( whetherTopMost) {
depth = depth - 1;
@ -555,8 +554,9 @@ class Tree {
}
print("\n\nWrote total $eventCounter events to file \"$gEventsFilename\" of which ${countPosts + 1} are posts.") ; // TODO remove extra 1
} on Exception catch (err) {
} on Exception catch (e) {
print("Could not open file $filename.");
if( gDebug > 0) print("Could not open file: $e");
}
return;
@ -899,7 +899,6 @@ class Tree {
void printSocialDistance(String otherPubkey, String otherName) {
String otherName = getAuthorName(otherPubkey);
List<String> contactList = [];
Event? contactEvent = this.getContactEvent(userPublicKey);
bool isFollow = false;
int numSecond = 0; // number of your follows who follow the other