mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 23:09:26 +08:00
48 lines
954 B
JavaScript
48 lines
954 B
JavaScript
import {
|
|
OPEN_MENU,
|
|
CLOSE_MENU,
|
|
OPEN_BAN_DIALOG,
|
|
CLOSE_BAN_DIALOG,
|
|
} from './constants';
|
|
|
|
const initialState = {
|
|
showMenuForComment: null,
|
|
showBanDialog: false,
|
|
authorId: null,
|
|
commentId: null,
|
|
commentStatus: 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_BAN_DIALOG:
|
|
return {
|
|
...state,
|
|
showBanDialog: true,
|
|
authorId: action.authorId,
|
|
commentId: action.commentId,
|
|
commentStatus: action.commentStatus,
|
|
};
|
|
case CLOSE_BAN_DIALOG:
|
|
return {
|
|
...state,
|
|
showBanDialog: false,
|
|
authorId: null,
|
|
commentId: null,
|
|
commentStatus: null,
|
|
};
|
|
default:
|
|
return state;
|
|
}
|
|
}
|