Skip to content

Commit

Permalink
no functional change
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalxl committed Aug 20, 2022
1 parent d4cc9fb commit 57ef23d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 42 deletions.
4 changes: 1 addition & 3 deletions bin/nostr_console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,10 @@ Future<void> main(List<String> arguments) async {
List<Event> eventsFromFile = readEventsFromFile(gEventsFilename);

setRelaysIntialEvents(eventsFromFile);
getRecievedEvents().forEach((element) { element.eventData.kind == 1? numFileEvents++: numFileEvents;});
eventsFromFile.forEach((element) { element.eventData.kind == 1? numFileEvents++: numFileEvents;});
print("read $numFileEvents posts from file \"$gEventsFilename\"");
//numFileEvents = getRecievedEvents().length;
}


// the default in case no arguments are given is:
// get a user's events, then from its type 3 event, gets events of its follows,
// then get the events of user-id's mentioned in p-tags of received events
Expand Down
3 changes: 0 additions & 3 deletions lib/console_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:nostr_console/relays.dart';
import 'package:crypto/crypto.dart';
import 'dart:convert'; // for the utf8.encode method


int showMenu(List<String> menuOptions, String menuName) {
print("\n$menuName\n${getNumDashes(menuName.length)}");
print('Pick an option:');
Expand Down Expand Up @@ -86,7 +85,6 @@ Future<void> otherMenuUi(Tree node, var contactList) async {
break;
}
}

return;
}

Expand Down Expand Up @@ -170,7 +168,6 @@ Future<void> mainMenuUi(Tree node, var contactList) async {
break;

case 3:
//print("\n\nNot yet implemented.");
otherMenuUi(node, contactList);
break;

Expand Down
40 changes: 6 additions & 34 deletions lib/event_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const int gMinValidTextWidth = 60; // minimum text width acceptable
const int gDefaultTextWidth = 120; // default text width
int gTextWidth = gDefaultTextWidth; // is changed by --width option
const int gSpacesPerDepth = 8; // constant
int gNumLeftMarginSpaces = 0; // this number is modified in main
String gAlignment = "center"; // is modified in main if --align argument is given
int gNumLeftMarginSpaces = 0;// this number is modified in main
String gAlignment = "center"; // is modified in main if --align argument is given
const int gapBetweenTopTrees = 1;

// after depth of maxDepthAllowed the thread is re-aligned to left by leftShiftThreadBy
Expand Down Expand Up @@ -133,7 +133,8 @@ class EventData {
return "";
}

EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content, this.eTagsRest, this.pTags, this.contactList, this.tags, this.newLikes, {this.isNotification = false});
EventData(this.id, this.pubkey, this.createdAt, this.kind, this.content, this.eTagsRest, this.pTags,
this.contactList, this.tags, this.newLikes, {this.isNotification = false});

factory EventData.fromJson(dynamic json) {
List<Contact> contactList = [];
Expand Down Expand Up @@ -359,22 +360,6 @@ List<String> getpTags(List<Event> events) {
return pTags;
}

int ascendingTime(Event a, Event b) {
if(a.eventData.createdAt < b.eventData.createdAt) {
return 0;
}
return 1;
}

void printEvents(List<Event> events) {
events.sort(ascendingTime);
for( int i = 0; i < events.length; i++) {
if( events[i].eventData.kind == 1) {
print('${events[i]}');
}
}
}

// If given event is kind 0 event, then populates gKindONames with that info
void processKind0Event(Event e) {
if( e.eventData.kind != 0) {
Expand Down Expand Up @@ -413,11 +398,10 @@ void printUserInfo(List<Event> events, String pub) {
}

List<Event> readEventsFromFile(String filename) {

List<Event> events = [];
final File file = File(filename);
final File file = File(filename);

// sync
// sync read
try {
List<String> lines = file.readAsLinesSync();
for( int i = 0; i < lines.length; i++ ) {
Expand All @@ -428,17 +412,5 @@ List<Event> readEventsFromFile(String filename) {
print("Cannot open file $gEventsFilename");
}

/*
while(true) {
try {
String strEvent = file.readAsStringSync();
//print(strEvent);
}
on Exception catch(e) {
break;
}
}*/

return events;
}
2 changes: 0 additions & 2 deletions lib/relays.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ void getMultiUserEvents(serverUrl, List<String> publicKeys, numUserEvents) {
}
}


void sendRequest(serverUrl, request) {
relays.sendRequest(serverUrl, request);
}
Expand All @@ -268,7 +267,6 @@ void clearEvents() {
relays.rEvents = [];
}


void setRelaysIntialEvents(eventsFromFile) {
relays.rEvents = eventsFromFile;
}
Expand Down

0 comments on commit 57ef23d

Please sign in to comment.