From 00c990d395e99243e7b569320f84a50c95e31a30 Mon Sep 17 00:00:00 2001 From: Vishal <64505169+vishalxl@users.noreply.github.com> Date: Thu, 17 Nov 2022 01:52:57 +0530 Subject: [PATCH] improved reply tag logic. issue 20c on github. --- Dockerfile | 14 ++++++++------ lib/event_ds.dart | 12 ++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66ef2fb..cefbc5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,9 @@ WORKDIR /app COPY pubspec.* ./ RUN dart pub get -#COPY . . +COPY . . RUN dart pub get --offline -#RUN dart compile exe bin/nostr_console.dart -o bin/nostr_console +RUN dart compile exe bin/nostr_console.dart -o bin/nostr_console FROM scratch COPY --from=build /runtime/ / @@ -32,13 +32,15 @@ RUN npm install node-pty dotenv RUN git config --global core.autocrlf input -RUN git clone https://github.com/cmdruid/nostr-terminal.git - -#COPY --from=build /app/bin/nostr_console /nostr-terminal/ +RUN git clone https://github.com/vishalxl/nostr-terminal.git +COPY --from=build /app/bin/nostr_console /nostr-terminal/ +RUN echo "/nostr-terminal/nostr_console --width=120 --align=left" >> /nostr-terminal/console.sh +RUN PATH=$PATH:/nostr-terminal/ #RUN chmod 755 /nostr-terminal/nostr_console WORKDIR /nostr-terminal/nostr-terminal RUN npm install -ENTRYPOINT ["yarn"] +#ENTRYPOINT ["/nostr-terminal/nostr_console"] +ENTRYPOINT [ "yarn" ] #CMD [ "yarn" ] diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 78b5095..0925d6c 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -144,9 +144,8 @@ class EventData { int numRoot = 0, numReply = 0; String rootId = "", replyId = ""; - for( int i = eTags.length - 1; i >= 0; i--) { + for( int i = 0; i < eTags.length; i++) { String eventId = eTags[i][0]; - //print(eTags); if( eTags[i].length >= 3) { if( eTags[i][2].toLowerCase() == "root") { numRoot++; @@ -164,11 +163,12 @@ class EventData { if( numReply == 1) { return replyId; } else { - if( rootId.length > 0) { - return rootId; + // if there are multiply reply's we can't tell which is which, so we return the one at top + if( replyId.length > 0) { + return replyId; } else { - if( replyId.length > 0) { - return replyId; + if( rootId.length > 0) { + return rootId; } } }