mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-07-18 00:02:19 +02:00
ran dart analyze and fixed issues
This commit is contained in:
@ -90,6 +90,7 @@ Future<void> main(List<String> arguments) async {
|
|||||||
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
||||||
} on StdoutException catch (e) {
|
} on StdoutException catch (e) {
|
||||||
print("Cannot find terminal size. Left aligning by default.");
|
print("Cannot find terminal size. Left aligning by default.");
|
||||||
|
if( gDebug > 0) log.info("${e.message}");
|
||||||
gNumLeftMarginSpaces = 0;
|
gNumLeftMarginSpaces = 0;
|
||||||
}
|
}
|
||||||
// undo above if left option is given
|
// undo above if left option is given
|
||||||
|
@ -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
|
// if contact list was found, get user's feed, and keep the contact list for later use
|
||||||
String authorName = gKindONames[pubkey.first]?.name??"";
|
String authorName = gKindONames[pubkey.first]?.name??"";
|
||||||
List<String> contactList = [];
|
|
||||||
printUnderlined("\nProfile for User");
|
printUnderlined("\nProfile for User");
|
||||||
print("\nName : $authorName ( ${pubkey.first} ).");
|
print("\nName : $authorName ( ${pubkey.first} ).");
|
||||||
|
|
||||||
@ -324,10 +323,12 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
|
|||||||
gNumLastDays = int.parse(newNumDays);
|
gNumLastDays = int.parse(newNumDays);
|
||||||
print("Changed number of days printed to $gNumLastDays");
|
print("Changed number of days printed to $gNumLastDays");
|
||||||
} on FormatException catch (e) {
|
} on FormatException catch (e) {
|
||||||
print("Invalid input. Kindly try again.");
|
print("Invalid input. Kindly try again.");
|
||||||
|
if( gDebug > 0) print(" ${e.message}");
|
||||||
continue;
|
continue;
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
print("Invalid input. Kindly try again.");
|
print("Invalid input. Kindly try again.");
|
||||||
|
if( gDebug > 0) print(" ${e}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,6 +454,8 @@ Future<void> mainMenuUi(Tree node, var contactList) async {
|
|||||||
}
|
}
|
||||||
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
||||||
} on StdoutException catch (e) {
|
} on StdoutException catch (e) {
|
||||||
|
print("Terminal information not available");
|
||||||
|
if( gDebug>0) print("${e.message}");
|
||||||
gNumLeftMarginSpaces = 0;
|
gNumLeftMarginSpaces = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ class EventData {
|
|||||||
try {
|
try {
|
||||||
translator
|
translator
|
||||||
.translate(content, to: 'en')
|
.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.")}
|
.then( (result) => { evaluatedContent = "$evaluatedContent\n\nTranslation: ${result.toString()}" , if( gDebug > 0) print("Google translate returned successfully for one call.")}
|
||||||
);
|
);
|
||||||
} on Exception catch(err) {
|
} on Exception catch(err) {
|
||||||
@ -344,9 +344,7 @@ class EventData {
|
|||||||
int n = 4;
|
int n = 4;
|
||||||
String maxN(String v) => v.length > n? v.substring(0,n) : v.substring(0, v.length);
|
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);
|
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
|
// TODO do it in one call
|
||||||
final df1 = DateFormat('hh:mm a');
|
final df1 = DateFormat('hh:mm a');
|
||||||
final df2 = DateFormat(DateFormat.YEAR_ABBR_MONTH_DAY);
|
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 );
|
return Event(json[0] as String, json[1] as String, EventData.fromJson(json[2]), [relay], d );
|
||||||
} on Exception catch(e) {
|
} on Exception catch(e) {
|
||||||
|
if( gDebug> 0) {
|
||||||
|
print("Could not create event. returning dummy event. $e");
|
||||||
|
}
|
||||||
return Event("","",EventData("non","", 0, 0, "", [], [], [], [[]], {}), [relay], "[json]");
|
return Event("","",EventData("non","", 0, 0, "", [], [], [], [[]], {}), [relay], "[json]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,8 +540,9 @@ Set<Event> readEventsFromFile(String filename) {
|
|||||||
Event e = Event.fromJson(lines[i], "");
|
Event e = Event.fromJson(lines[i], "");
|
||||||
events.add(e);
|
events.add(e);
|
||||||
}
|
}
|
||||||
} on Exception catch(err) {
|
} on Exception catch(e) {
|
||||||
print("cannot open file $gEventsFilename");
|
print("cannot open file $gEventsFilename");
|
||||||
|
print("Could not open file. error = $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
|
@ -90,7 +90,6 @@ class Tree {
|
|||||||
rooms[chatRoomId]?.name = json['name'];
|
rooms[chatRoomId]?.name = json['name'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<String> temp = [];
|
|
||||||
String roomName = "", roomAbout = "";
|
String roomName = "", roomAbout = "";
|
||||||
if( json.containsKey('name') ) {
|
if( json.containsKey('name') ) {
|
||||||
roomName = json['name'];
|
roomName = json['name'];
|
||||||
@ -104,7 +103,7 @@ class Tree {
|
|||||||
//if( gDebug > 0) print("Added new chat room $chatRoomId with name ${json['name']} .");
|
//if( gDebug > 0) print("Added new chat room $chatRoomId with name ${json['name']} .");
|
||||||
}
|
}
|
||||||
} on Exception catch(e) {
|
} 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;
|
int numPrinted = 0;
|
||||||
|
|
||||||
// for the top most tree, create a smaller list which only has recent trees
|
// for the top most tree, create a smaller list which only has recent trees
|
||||||
List<Tree> latestTrees = []; // TODO
|
//List<Tree> latestTrees = []; // TODO
|
||||||
|
|
||||||
if( whetherTopMost) {
|
if( whetherTopMost) {
|
||||||
depth = depth - 1;
|
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
|
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.");
|
print("Could not open file $filename.");
|
||||||
|
if( gDebug > 0) print("Could not open file: $e");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -899,7 +899,6 @@ class Tree {
|
|||||||
void printSocialDistance(String otherPubkey, String otherName) {
|
void printSocialDistance(String otherPubkey, String otherName) {
|
||||||
String otherName = getAuthorName(otherPubkey);
|
String otherName = getAuthorName(otherPubkey);
|
||||||
|
|
||||||
List<String> contactList = [];
|
|
||||||
Event? contactEvent = this.getContactEvent(userPublicKey);
|
Event? contactEvent = this.getContactEvent(userPublicKey);
|
||||||
bool isFollow = false;
|
bool isFollow = false;
|
||||||
int numSecond = 0; // number of your follows who follow the other
|
int numSecond = 0; // number of your follows who follow the other
|
||||||
|
Reference in New Issue
Block a user