11import { Thread } from './types' ;
22import { startLoadSync , stopLoadSync } from './activity' ;
3+ import { updateLabelSuccess } from './labels' ;
34import {
45 createEmailLabel ,
56 deleteEmailLabel ,
@@ -106,7 +107,20 @@ export const moveThreads = (threadIds, labelId) => ({
106107 labelId
107108} ) ;
108109
109- export const markThreadsRead = ( threadsParams , read ) => {
110+ export const updateUnreadThread = thread => {
111+ return {
112+ type : Thread . UPDATE_UNREAD_THREAD ,
113+ thread
114+ } ;
115+ } ;
116+
117+ export const updateUnreadThreadsSuccess = ( threadsIds , read ) => ( {
118+ threadsIds,
119+ read,
120+ type : Thread . UPDATE_UNREAD_THREADS
121+ } ) ;
122+
123+ export const updateUnreadThreads = ( threadsParams , read , label ) => {
110124 return async dispatch => {
111125 try {
112126 const storeIds = threadsParams . map ( param => param . threadIdStore ) ;
@@ -117,20 +131,15 @@ export const markThreadsRead = (threadsParams, read) => {
117131 } )
118132 ) ;
119133 if ( dbReponse ) {
120- dispatch ( markThreadsReadSuccess ( storeIds , read ) ) ;
134+ dispatch ( updateUnreadThreadsSuccess ( storeIds , read ) ) ;
135+ if ( label ) dispatch ( updateLabelSuccess ( label ) ) ;
121136 }
122137 } catch ( e ) {
123138 // To do
124139 }
125140 } ;
126141} ;
127142
128- export const markThreadsReadSuccess = ( threadsIds , read ) => ( {
129- threadsIds,
130- read,
131- type : Thread . UPDATE_UNREAD
132- } ) ;
133-
134143export const searchThreads = params => {
135144 return async dispatch => {
136145 try {
0 commit comments