@@ -2046,6 +2046,42 @@ describe("Room", function() {
20462046 expect ( thread . replyToEvent . getId ( ) ) . toBe ( threadResponse2 . getId ( ) ) ;
20472047 } ) ;
20482048
2049+ it ( "should not decrement the length when the thread root is redacted" , async ( ) => {
2050+ room . client . supportsExperimentalThreads = ( ) => true ;
2051+
2052+ const threadRoot = mkMessage ( ) ;
2053+ const threadResponse1 = mkThreadResponse ( threadRoot ) ;
2054+ threadResponse1 . localTimestamp += 1000 ;
2055+ const threadResponse2 = mkThreadResponse ( threadRoot ) ;
2056+ threadResponse2 . localTimestamp += 2000 ;
2057+ const threadResponse2Reaction = mkReaction ( threadResponse2 ) ;
2058+
2059+ room . client . fetchRoomEvent = ( eventId : string ) => Promise . resolve ( {
2060+ ...threadRoot . event ,
2061+ unsigned : {
2062+ "age" : 123 ,
2063+ "m.relations" : {
2064+ "m.thread" : {
2065+ latest_event : threadResponse2 . event ,
2066+ count : 2 ,
2067+ current_user_participated : true ,
2068+ } ,
2069+ } ,
2070+ } ,
2071+ } ) ;
2072+
2073+ room . addLiveEvents ( [ threadRoot , threadResponse1 , threadResponse2 , threadResponse2Reaction ] ) ;
2074+ const thread = await emitPromise ( room , ThreadEvent . New ) ;
2075+
2076+ expect ( thread ) . toHaveLength ( 2 ) ;
2077+ expect ( thread . replyToEvent . getId ( ) ) . toBe ( threadResponse2 . getId ( ) ) ;
2078+
2079+ const threadRootRedaction = mkRedaction ( threadRoot ) ;
2080+ room . addLiveEvents ( [ threadRootRedaction ] ) ;
2081+ await emitPromise ( thread , ThreadEvent . Update ) ;
2082+ expect ( thread ) . toHaveLength ( 2 ) ;
2083+ } ) ;
2084+
20492085 it ( "Redacting the lastEvent finds a new lastEvent" , async ( ) => {
20502086 room . client . supportsExperimentalThreads = ( ) => true ;
20512087
0 commit comments