@@ -916,30 +916,48 @@ var Gmail = function() {
916
916
917
917
if ( api . check . is_conversation_view ( ) ) {
918
918
displayed_email_data = email_data ;
919
+
920
+ var threads = displayed_email_data . threads ;
921
+ var total_threads = displayed_email_data . total_threads ;
922
+
923
+ var hash = window . location . hash . split ( '#' ) [ 1 ] || '' ;
924
+ var is_in_trash = ( hash . indexOf ( 'trash' ) === 0 ) ;
925
+
926
+ for ( id in threads ) {
927
+ var email = threads [ id ] ;
928
+ var keep_email = ( is_in_trash ) ? email . is_deleted : ! email . is_deleted ;
929
+
930
+ if ( ! keep_email ) {
931
+ delete threads [ id ] ;
932
+ total_threads . splice ( total_threads . indexOf ( id ) , 1 ) ;
933
+ displayed_email_data . total_emails -- ;
934
+ // TODO: remove people involved only in this email.
935
+ }
936
+ }
919
937
}
920
938
else { // Supposing only one displayed email.
921
939
for ( id in email_data . threads ) {
922
940
var displayed_email_element = $ ( '.ii.gt[class*="' + id + '"]' ) ;
923
941
924
942
if ( displayed_email_element . length > 0 ) {
925
- var thread = email_data . threads [ id ] ;
943
+ var email = email_data . threads [ id ] ;
926
944
927
945
displayed_email_data . first_email = id ;
928
946
displayed_email_data . last_email = id ;
929
947
displayed_email_data . subject = email_data . subject ;
930
948
931
949
displayed_email_data . threads = { } ;
932
- displayed_email_data . threads [ id ] = thread ;
950
+ displayed_email_data . threads [ id ] = email ;
933
951
displayed_email_data . total_emails = 1 ;
934
952
displayed_email_data . total_threads = [ id ] ;
935
953
936
954
displayed_email_data . people_involved = [ ] ;
937
955
938
956
displayed_email_data . people_involved . push (
939
- [ thread . from , thread . from_email ]
957
+ [ email . from , email . from_email ]
940
958
) ;
941
959
942
- thread . to . forEach ( function ( recipient ) {
960
+ email . to . forEach ( function ( recipient ) {
943
961
var address = api . tools . extract_email_address ( recipient ) ;
944
962
var name = api . tools . extract_name ( recipient . replace ( address , '' ) ) || '' ;
945
963
@@ -964,7 +982,7 @@ var Gmail = function() {
964
982
var flag = undefined ;
965
983
var array_with_flag = api . tracker . globals [ 17 ] [ 5 ] [ 1 ] ;
966
984
967
- for ( var i = 0 ; i < array_with_flag . length ; i ++ ) {
985
+ for ( var i = 0 ; i < array_with_flag . length ; i ++ ) {
968
986
var current = array_with_flag [ i ] ;
969
987
970
988
if ( current [ 0 ] === flag_name ) {
0 commit comments