@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ import { Optional } from "matrix-events-sdk" ;
18+
1719import { MatrixClient , MatrixEventEvent , RelationType , RoomEvent } from "../matrix" ;
1820import { TypedReEmitter } from "../ReEmitter" ;
1921import { IRelationsRequestOpts } from "../@types/requests" ;
@@ -328,15 +330,16 @@ export class Thread extends TypedEventEmitter<EmittedEvents, EventHandlerMap> {
328330 }
329331
330332 /**
331- * Return last reply to the thread
333+ * Return last reply to the thread, if known.
332334 */
333- public lastReply ( matches : ( ev : MatrixEvent ) => boolean = ( ) => true ) : MatrixEvent {
335+ public lastReply ( matches : ( ev : MatrixEvent ) => boolean = ( ) => true ) : Optional < MatrixEvent > {
334336 for ( let i = this . events . length - 1 ; i >= 0 ; i -- ) {
335337 const event = this . events [ i ] ;
336338 if ( matches ( event ) ) {
337339 return event ;
338340 }
339341 }
342+ return null ;
340343 }
341344
342345 public get roomId ( ) : string {
@@ -353,9 +356,9 @@ export class Thread extends TypedEventEmitter<EmittedEvents, EventHandlerMap> {
353356 }
354357
355358 /**
356- * A getter for the last event added to the thread
359+ * A getter for the last event added to the thread, if known.
357360 */
358- public get replyToEvent ( ) : MatrixEvent {
361+ public get replyToEvent ( ) : Optional < MatrixEvent > {
359362 return this . lastEvent ?? this . lastReply ( ) ;
360363 }
361364
0 commit comments