mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 12:02:46 +08:00
38 lines
721 B
JavaScript
38 lines
721 B
JavaScript
import {OPEN_MENU, CLOSE_MENU, OPEN_DIALOG, CLOSE_DIALOG} from './constants';
|
|
|
|
const initialState = {
|
|
showMenuForComment: null,
|
|
showDialog: false,
|
|
comment: null
|
|
};
|
|
|
|
export default function reducer(state = initialState, action) {
|
|
switch (action.type) {
|
|
case OPEN_MENU:
|
|
return {
|
|
...state,
|
|
showMenuForComment: action.id
|
|
};
|
|
case CLOSE_MENU:
|
|
return {
|
|
...state,
|
|
showMenuForComment: null
|
|
};
|
|
case OPEN_DIALOG:
|
|
return {
|
|
...state,
|
|
showDialog: true,
|
|
commentId: action.commentId,
|
|
authorId: action.authorId
|
|
};
|
|
case CLOSE_DIALOG:
|
|
return {
|
|
...state,
|
|
showDialog: false,
|
|
comment: null
|
|
};
|
|
default :
|
|
return state;
|
|
}
|
|
}
|