Browse Source

Convert login reducer state to an immutable record.

pull/1/head
Titouan Rigoudy 9 years ago
parent
commit
8b5cddb69d
5 changed files with 15 additions and 11 deletions
  1. +1
    -2
      src/containers/ConnectPage.js
  2. +5
    -5
      src/containers/Footer.js
  3. +1
    -1
      src/containers/RoomsPane.js
  4. +1
    -1
      src/createRoutes.js
  5. +7
    -2
      src/reducers/login.js

+ 1
- 2
src/containers/ConnectPage.js View File

@ -33,8 +33,7 @@ class ConnectPage extends React.Component {
const { actions, login, router, socket } = props;
if (socket.state === STATE_OPEN)
{
const loginStatus = login.get("status");
switch (loginStatus) {
switch (login.status) {
case LOGIN_STATUS_UNKNOWN:
actions.login.getStatus();
break;


+ 5
- 5
src/containers/Footer.js View File

@ -13,17 +13,17 @@ const Footer = ({ login, socket }) => {
url={socket.url}
/>
<LoginStatusPane
status={login.get("status")}
username={login.get("username")}
motd={login.get("motd")}
reason={login.get("reason")}
status={login.status}
username={login.username}
motd={login.motd}
reason={login.reason}
/>
</footer>
);
};
Footer.propTypes = {
login: ImmutablePropTypes.map.isRequired,
login: ImmutablePropTypes.record.isRequired,
socket: ImmutablePropTypes.record.isRequired
};


+ 1
- 1
src/containers/RoomsPane.js View File

@ -61,7 +61,7 @@ RoomsPane.propTypes = {
};
const mapStateToProps = (state) => ({
loginUserName: state.login.get("username"),
loginUserName: state.login.username,
rooms: state.rooms
});


+ 1
- 1
src/createRoutes.js View File

@ -14,7 +14,7 @@ const createRoutes = (store) => {
const requireLoggedIn = (nextState, replaceState) => {
let { socket, login } = store.getState();
if (socket.state !== STATE_OPEN ||
login.get("status") !== LOGIN_STATUS_SUCCESS)
login.status !== LOGIN_STATUS_SUCCESS)
{
replaceState({}, "/");
}


+ 7
- 2
src/reducers/login.js View File

@ -13,10 +13,15 @@ import {
LOGIN_STATUS_FAILURE
} from "../constants/login";
const initialState = Immutable.Map({
status: LOGIN_STATUS_UNKNOWN
const LoginRecord = Immutable.Record({
status: LOGIN_STATUS_UNKNOWN,
username: undefined,
motd: undefined,
reason: undefined
});
const initialState = new LoginRecord();
const reduceReceiveMessage = (state, message) => {
const { variant, data } = message;


Loading…
Cancel
Save