diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 8025562..2c260ca 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -786,7 +786,7 @@ class EventData { } - String getStrForChannel(int depth, var tempChildEventsMap, Set? secretMessageIds, List? encryptedChannels) { + String getStrForChannel(int depth, Map tempChildEventsMap, Set? secretMessageIds, List? encryptedChannels) { // will only do decryption if its not been decrypted yet by looking at 'evaluatedContent' // will only do decryption if its not been decrypted yet by looking at 'evaluatedContent' @@ -839,7 +839,7 @@ class EventData { String contentShifted = makeParagraphAtDepth(tempEvaluatedContent, finalContentDepthInSpaces); - Event? replyToEvent = getReplyToEvent(); + Event? replyToEvent = getReplyToChannelEvent(tempChildEventsMap); String strReplyTo = ""; if( replyToEvent != null) { //print("in getStrForChannel: got replyTo id = ${replyToEvent.eventData.id}"); @@ -912,21 +912,30 @@ class EventData { } // returns the last e tag as reply to event for kind 42 and 142 events - Event? getReplyToEvent() { - for(int i = tags.length - 1; i >= 0; i--) { - List tag = tags[i]; - if( tag[0] == 'e') { - String replyToEventId = tag[1]; - Event? eventInReplyTo = (gStore?.allChildEventsMap[replyToEventId]?.event)??null; - if( eventInReplyTo != null) { - if ( [1,42,142].contains( eventInReplyTo.eventData.kind)) { - return eventInReplyTo; + Event? getReplyToChannelEvent(Map tempChildEventsMap) { + switch (this.kind) { + case 42: + case 142: + for(int i = tags.length - 1; i >= 0; i--) { + List tag = tags[i]; + if( tag[0] == 'e') { + String replyToEventId = tag[1]; + Event? eventInReplyTo = (gStore?.allChildEventsMap[replyToEventId]?.event)??null; + if( eventInReplyTo != null) { + // add 1 cause 42 can reply to or tag kind 1, and we'll show that kind 1 + if ( [1,42,142].contains( eventInReplyTo.eventData.kind)) { + return eventInReplyTo; + } } } } - } + break; + case 1: + String replyToId = getParent(tempChildEventsMap); + return tempChildEventsMap[replyToId]?.event; + } // end of switch return null; - } // end getReplyToEvent() + } // end getReplyToChannelEvent() } // This is mostly a placeholder for EventData. TODO combine both? diff --git a/pubspec.yaml b/pubspec.yaml index bbc804d..d7e0dce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/vishalxl/nostr_console # crated location and t rooms -# t tags added for all tags +# t tags added for all tags environment: sdk: '>=2.17.3 <3.0.0'