From 784d4e401039ce47087e8c44cf9654a34d98b7c0 Mon Sep 17 00:00:00 2001 From: OfficialDakari Date: Tue, 21 Oct 2025 19:20:12 +0500 Subject: [PATCH] implement Thread.sendTextEvent --- lib/src/thread.dart | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lib/src/thread.dart b/lib/src/thread.dart index fc68bc48..441c3f0f 100644 --- a/lib/src/thread.dart +++ b/lib/src/thread.dart @@ -77,4 +77,52 @@ class Thread { return event; } + + /// When was the last event received. + DateTime get latestEventReceivedTime { + final lastEventTime = lastEvent?.originServerTs; + if (lastEventTime != null) return lastEventTime; + + if (room.membership == Membership.invite) return DateTime.now(); + + return rootEvent.originServerTs; + } + + bool get hasNewMessages { + // TODO: Implement this + return false; + } + + Future sendTextEvent( + String message, { + String? txid, + Event? inReplyTo, + String? editEventId, + bool parseMarkdown = true, + bool parseCommands = true, + String msgtype = MessageTypes.Text, + StringBuffer? commandStdout, + bool addMentions = true, + + /// Displays an event in the timeline with the transaction ID as the event + /// ID and a status of SENDING, SENT or ERROR until it gets replaced by + /// the sync event. Using this can display a different sort order of events + /// as the sync event does replace but not relocate the pending event. + bool displayPendingEvent = true, + }) { + return room.sendTextEvent( + message, + txid: txid, + inReplyTo: inReplyTo, + editEventId: editEventId, + parseCommands: parseCommands, + parseMarkdown: parseMarkdown, + msgtype: msgtype, + commandStdout: commandStdout, + addMentions: addMentions, + displayPendingEvent: displayPendingEvent, + threadLastEventId: lastEvent?.eventId, + threadRootEventId: rootEvent.eventId, + ); + } }