@@ -2849,7 +2849,7 @@ describe("Room", function () {
2849
2849
Thread . setServerSideSupport ( FeatureSupport . Stable ) ;
2850
2850
const room = new Room ( roomId , client , userA ) ;
2851
2851
2852
- it ( "thread root and its relations&redactions should be in both " , ( ) => {
2852
+ it ( "thread root and its relations&redactions should be in main timeline " , ( ) => {
2853
2853
const randomMessage = mkMessage ( ) ;
2854
2854
const threadRoot = mkMessage ( ) ;
2855
2855
const threadResponse1 = mkThreadResponse ( threadRoot ) ;
@@ -2867,6 +2867,9 @@ describe("Room", function () {
2867
2867
threadReaction2Redaction ,
2868
2868
] ;
2869
2869
2870
+ const thread = room . createThread ( threadRoot . getId ( ) ! , threadRoot , [ ] , false ) ;
2871
+ events . slice ( 1 ) . forEach ( ( ev ) => ev . setThread ( thread ) ) ;
2872
+
2870
2873
expect ( room . eventShouldLiveIn ( randomMessage , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2871
2874
expect ( room . eventShouldLiveIn ( randomMessage , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2872
2875
@@ -2878,14 +2881,11 @@ describe("Room", function () {
2878
2881
expect ( room . eventShouldLiveIn ( threadResponse1 , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2879
2882
2880
2883
expect ( room . eventShouldLiveIn ( threadReaction1 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2881
- expect ( room . eventShouldLiveIn ( threadReaction1 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2882
- expect ( room . eventShouldLiveIn ( threadReaction1 , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2884
+ expect ( room . eventShouldLiveIn ( threadReaction1 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2883
2885
expect ( room . eventShouldLiveIn ( threadReaction2 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2884
- expect ( room . eventShouldLiveIn ( threadReaction2 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2885
- expect ( room . eventShouldLiveIn ( threadReaction2 , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2886
+ expect ( room . eventShouldLiveIn ( threadReaction2 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2886
2887
expect ( room . eventShouldLiveIn ( threadReaction2Redaction , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2887
- expect ( room . eventShouldLiveIn ( threadReaction2Redaction , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2888
- expect ( room . eventShouldLiveIn ( threadReaction2Redaction , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2888
+ expect ( room . eventShouldLiveIn ( threadReaction2Redaction , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2889
2889
} ) ;
2890
2890
2891
2891
it ( "thread response and its relations&redactions should be only in thread timeline" , ( ) => {
@@ -2909,25 +2909,39 @@ describe("Room", function () {
2909
2909
expect ( room . eventShouldLiveIn ( threadReaction2Redaction , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2910
2910
} ) ;
2911
2911
2912
- it ( "reply to thread response and its relations&redactions should be only in main timeline" , ( ) => {
2912
+ it ( "reply to thread response and its relations&redactions should be only in thread timeline" , ( ) => {
2913
2913
const threadRoot = mkMessage ( ) ;
2914
- const threadResponse1 = mkThreadResponse ( threadRoot ) ;
2915
- const reply1 = mkReply ( threadResponse1 ) ;
2916
- const reaction1 = utils . mkReaction ( reply1 , room . client , userA , roomId ) ;
2917
- const reaction2 = utils . mkReaction ( reply1 , room . client , userA , roomId ) ;
2918
- const reaction2Redaction = mkRedaction ( reply1 ) ;
2914
+ const threadResp1 = mkThreadResponse ( threadRoot ) ;
2915
+ const threadResp1Reply1 = mkReply ( threadResp1 ) ;
2916
+ const threadResp1Reply1Reaction1 = utils . mkReaction ( threadResp1Reply1 , room . client , userA , roomId ) ;
2917
+ const threadResp1Reply1Reaction2 = utils . mkReaction ( threadResp1Reply1 , room . client , userA , roomId ) ;
2918
+ const thResp1Rep1React2Redaction = mkRedaction ( threadResp1Reply1 ) ;
2919
2919
2920
2920
const roots = new Set ( [ threadRoot . getId ( ) ! ] ) ;
2921
- const events = [ threadRoot , threadResponse1 , reply1 , reaction1 , reaction2 , reaction2Redaction ] ;
2921
+ const events = [
2922
+ threadRoot ,
2923
+ threadResp1 ,
2924
+ threadResp1Reply1 ,
2925
+ threadResp1Reply1Reaction1 ,
2926
+ threadResp1Reply1Reaction2 ,
2927
+ thResp1Rep1React2Redaction ,
2928
+ ] ;
2922
2929
2923
- expect ( room . eventShouldLiveIn ( reply1 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2924
- expect ( room . eventShouldLiveIn ( reply1 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2925
- expect ( room . eventShouldLiveIn ( reaction1 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2926
- expect ( room . eventShouldLiveIn ( reaction1 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2927
- expect ( room . eventShouldLiveIn ( reaction2 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2928
- expect ( room . eventShouldLiveIn ( reaction2 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2929
- expect ( room . eventShouldLiveIn ( reaction2Redaction , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2930
- expect ( room . eventShouldLiveIn ( reaction2Redaction , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2930
+ const thread = room . createThread ( threadRoot . getId ( ) ! , threadRoot , [ ] , false ) ;
2931
+ events . forEach ( ( ev ) => ev . setThread ( thread ) ) ;
2932
+
2933
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1 , events , roots ) . shouldLiveInRoom ) . toBeFalsy ( ) ;
2934
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2935
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1 , events , roots ) . threadId ) . toBe ( thread . id ) ;
2936
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction1 , events , roots ) . shouldLiveInRoom ) . toBeFalsy ( ) ;
2937
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction1 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2938
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction1 , events , roots ) . threadId ) . toBe ( thread . id ) ;
2939
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction2 , events , roots ) . shouldLiveInRoom ) . toBeFalsy ( ) ;
2940
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction2 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2941
+ expect ( room . eventShouldLiveIn ( threadResp1Reply1Reaction2 , events , roots ) . threadId ) . toBe ( thread . id ) ;
2942
+ expect ( room . eventShouldLiveIn ( thResp1Rep1React2Redaction , events , roots ) . shouldLiveInRoom ) . toBeFalsy ( ) ;
2943
+ expect ( room . eventShouldLiveIn ( thResp1Rep1React2Redaction , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2944
+ expect ( room . eventShouldLiveIn ( thResp1Rep1React2Redaction , events , roots ) . threadId ) . toBe ( thread . id ) ;
2931
2945
} ) ;
2932
2946
2933
2947
it ( "reply to reply to thread root should only be in the main timeline" , ( ) => {
@@ -2939,12 +2953,40 @@ describe("Room", function () {
2939
2953
const roots = new Set ( [ threadRoot . getId ( ) ! ] ) ;
2940
2954
const events = [ threadRoot , threadResponse1 , reply1 , reply2 ] ;
2941
2955
2956
+ const thread = room . createThread ( threadRoot . getId ( ) ! , threadRoot , [ ] , false ) ;
2957
+ threadResponse1 . setThread ( thread ) ;
2958
+
2942
2959
expect ( room . eventShouldLiveIn ( reply1 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2943
2960
expect ( room . eventShouldLiveIn ( reply1 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2944
2961
expect ( room . eventShouldLiveIn ( reply2 , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2945
2962
expect ( room . eventShouldLiveIn ( reply2 , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2946
2963
} ) ;
2947
2964
2965
+ it ( "edit to thread root should live in main timeline only" , ( ) => {
2966
+ const threadRoot = mkMessage ( ) ;
2967
+ const threadResponse1 = mkThreadResponse ( threadRoot ) ;
2968
+ const threadRootEdit = mkEdit ( threadRoot ) ;
2969
+ threadRoot . makeReplaced ( threadRootEdit ) ;
2970
+
2971
+ const thread = room . createThread ( threadRoot . getId ( ) ! , threadRoot , [ threadResponse1 ] , false ) ;
2972
+ threadResponse1 . setThread ( thread ) ;
2973
+ threadRootEdit . setThread ( thread ) ;
2974
+
2975
+ const roots = new Set ( [ threadRoot . getId ( ) ! ] ) ;
2976
+ const events = [ threadRoot , threadResponse1 , threadRootEdit ] ;
2977
+
2978
+ expect ( room . eventShouldLiveIn ( threadRoot , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2979
+ expect ( room . eventShouldLiveIn ( threadRoot , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2980
+ expect ( room . eventShouldLiveIn ( threadRoot , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2981
+
2982
+ expect ( room . eventShouldLiveIn ( threadResponse1 , events , roots ) . shouldLiveInRoom ) . toBeFalsy ( ) ;
2983
+ expect ( room . eventShouldLiveIn ( threadResponse1 , events , roots ) . shouldLiveInThread ) . toBeTruthy ( ) ;
2984
+ expect ( room . eventShouldLiveIn ( threadResponse1 , events , roots ) . threadId ) . toBe ( threadRoot . getId ( ) ) ;
2985
+
2986
+ expect ( room . eventShouldLiveIn ( threadRootEdit , events , roots ) . shouldLiveInRoom ) . toBeTruthy ( ) ;
2987
+ expect ( room . eventShouldLiveIn ( threadRootEdit , events , roots ) . shouldLiveInThread ) . toBeFalsy ( ) ;
2988
+ } ) ;
2989
+
2948
2990
it ( "should aggregate relations in thread event timeline set" , async ( ) => {
2949
2991
Thread . setServerSideSupport ( FeatureSupport . Stable ) ;
2950
2992
const threadRoot = mkMessage ( ) ;
0 commit comments