client/src/sagas/index.js
changeset 53 d8588379529e
parent 47 64428c7ebc19
child 54 fad489be9c77
equal deleted inserted replaced
52:96f8a4a59bd9 53:d8588379529e
   135     const { token } = yield take(types.AUTH_STORE_TOKEN_ASYNC);
   135     const { token } = yield take(types.AUTH_STORE_TOKEN_ASYNC);
   136     yield put({ type: types.AUTH_STORE_TOKEN, token });
   136     yield put({ type: types.AUTH_STORE_TOKEN, token });
   137   }
   137   }
   138 }
   138 }
   139 
   139 
       
   140 function* watchUpdateSettings() {
       
   141   while (true) {
       
   142     const { username, firstname, lastname } = yield take(types.USER_UPDATE_SETTINGS_ASYNC);
       
   143     try {
       
   144       yield client.put('/api/auth/user/', {
       
   145         username,
       
   146         first_name: firstname,
       
   147         last_name: lastname
       
   148       });
       
   149       yield put({ type: types.USER_UPDATE_SETTINGS, firstname, lastname });
       
   150     } catch (e) {
       
   151 
       
   152     }
       
   153   }
       
   154 }
       
   155 
   140 // ---
   156 // ---
   141 
   157 
   142 export default function* rootSaga() {
   158 export default function* rootSaga() {
   143   yield all([
   159   yield all([
   144     watchLoadSessions(),
   160     watchLoadSessions(),
   147     watchCreateSession(),
   163     watchCreateSession(),
   148     watchUpdateSession(),
   164     watchUpdateSession(),
   149     watchLoginSubmit(),
   165     watchLoginSubmit(),
   150     watchLoginRequest(),
   166     watchLoginRequest(),
   151     watchStoreToken(),
   167     watchStoreToken(),
       
   168     watchUpdateSettings(),
   152   ])
   169   ])
   153 }
   170 }