@@ -16,44 +16,7 @@ class ThreadsWrapper extends Component {
1616 tip : '' ,
1717 popupContent : undefined
1818 } ;
19- }
20-
21- componentWillReceiveProps ( nextProps ) {
22- if (
23- this . props . mailboxSelected !== nextProps . mailboxSelected ||
24- this . props . searchParams !== nextProps . searchParams ||
25- ( nextProps . threadItemsChecked . size === 0 &&
26- this . props . threadItemsChecked . size > 0 )
27- ) {
28- this . setState ( { lastMinDate : undefined } ) ;
29- this . props . onLoadThreads (
30- nextProps . mailboxSelected ,
31- true ,
32- nextProps . searchParams
33- ) ;
34- }
35- if (
36- this . props . threadItemsChecked . size > 0 &&
37- this . props . mailboxSelected !== nextProps . mailboxSelected
38- ) {
39- this . props . onBackOption ( ) ;
40- }
41-
42- if (
43- this . state . isHiddenLoadingSync &&
44- nextProps . totalTask > nextProps . completedTask
45- ) {
46- this . setState ( { isHiddenLoadingSync : false } ) ;
47- }
48- if (
49- ! this . state . isHiddenLoadingSync &&
50- nextProps . totalTask > 0 &&
51- nextProps . completedTask > 0 &&
52- ( nextProps . totalTask === nextProps . completedTask ||
53- nextProps . completedTask > nextProps . totalTask )
54- ) {
55- setTimeout ( ( ) => this . setState ( { isHiddenLoadingSync : true } ) , 1000 ) ;
56- }
19+ this . scroll = null ;
5720 }
5821
5922 render ( ) {
@@ -68,6 +31,7 @@ class ThreadsWrapper extends Component {
6831 onMouseLeaveItem = { this . handleMouseLeaveItem }
6932 onScroll = { this . handleScroll }
7033 onChangeSwitch = { this . handleChangeSwitch }
34+ setScrollRef = { this . handleSetScrollRef }
7135 tip = { this . state . tip }
7236 popupContent = { this . state . popupContent }
7337 setPopupContent = { this . setPopupContent }
@@ -82,6 +46,46 @@ class ThreadsWrapper extends Component {
8246 this . props . onLoadApp ( this . props . mailboxSelected , true ) ;
8347 }
8448
49+ componentDidUpdate ( prevProps ) {
50+ if (
51+ prevProps . mailboxSelected !== this . props . mailboxSelected ||
52+ prevProps . searchParams !== this . props . searchParams ||
53+ ( this . props . threadItemsChecked . size === 0 &&
54+ prevProps . threadItemsChecked . size > 0 )
55+ ) {
56+ this . setState ( { lastMinDate : undefined } ) ;
57+ this . props . onLoadThreads (
58+ this . props . mailboxSelected ,
59+ true ,
60+ this . props . searchParams
61+ ) ;
62+ if ( this . scroll . scrollTop !== 0 ) {
63+ this . scroll . scrollTop = 0 ;
64+ }
65+ }
66+ if (
67+ this . props . threadItemsChecked . size > 0 &&
68+ prevProps . mailboxSelected !== this . props . mailboxSelected
69+ ) {
70+ this . props . onBackOption ( ) ;
71+ }
72+ if (
73+ this . state . isHiddenLoadingSync &&
74+ this . props . totalTask > this . props . completedTask
75+ ) {
76+ this . setState ( { isHiddenLoadingSync : false } ) ;
77+ }
78+ if (
79+ ! this . state . isHiddenLoadingSync &&
80+ this . props . totalTask > 0 &&
81+ this . props . completedTask > 0 &&
82+ ( this . props . totalTask === this . props . completedTask ||
83+ this . props . completedTask > this . props . totalTask )
84+ ) {
85+ setTimeout ( ( ) => this . setState ( { isHiddenLoadingSync : true } ) , 1000 ) ;
86+ }
87+ }
88+
8589 handleCloseMessage = ( ) => {
8690 if ( this . props . isUpdateAvailable ) {
8791 this . props . onCloseUpdateMessage ( ) ;
@@ -159,6 +163,10 @@ class ThreadsWrapper extends Component {
159163 this . setState ( { popupContent : undefined } , this . props . onEmptyTrash ) ;
160164 } ;
161165
166+ handleSetScrollRef = e => {
167+ this . scroll = e ;
168+ } ;
169+
162170 setPopupContent = popupContent => {
163171 this . setState ( { popupContent } ) ;
164172 } ;
0 commit comments