mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added delete message action
This commit is contained in:
parent
47cd66496b
commit
600b8bb1e8
3 changed files with 15 additions and 2 deletions
|
@ -15,16 +15,22 @@ const mapStateToProps = state => ({
|
|||
|
||||
const mapDispatchToProps = {
|
||||
authGetMessages: AUTH_ACTIONS.authGetMessages,
|
||||
authDeleteMessage: AUTH_ACTIONS.authDeleteMessage,
|
||||
};
|
||||
|
||||
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
|
||||
|
||||
const ProfileMessagesUnconnected: FC<IProps> = ({ profile, user: { id }, authGetMessages }) => {
|
||||
const ProfileMessagesUnconnected: FC<IProps> = ({
|
||||
profile,
|
||||
user: { id },
|
||||
authGetMessages,
|
||||
authDeleteMessage,
|
||||
}) => {
|
||||
const [editingMessageId, setEditingMessageId] = useState(0);
|
||||
|
||||
const onEditMessage = useCallback((id: number) => setEditingMessageId(id), [setEditingMessageId]);
|
||||
const onCancelEdit = useCallback(() => setEditingMessageId(0), [setEditingMessageId]);
|
||||
const onDeleteMessage = useCallback((id: number) => console.log({ id }), []);
|
||||
const onDeleteMessage = useCallback((id: number) => authDeleteMessage(id), [authDeleteMessage]);
|
||||
|
||||
useEffect(() => {
|
||||
if (profile.is_loading || !profile.user || !profile.user.username) return;
|
||||
|
|
|
@ -65,6 +65,11 @@ export const authSendMessage = (message: Partial<IMessage>, onSuccess) => ({
|
|||
onSuccess,
|
||||
});
|
||||
|
||||
export const authDeleteMessage = (id: IMessage['id']) => ({
|
||||
type: AUTH_USER_ACTIONS.DELETE_MESSAGE,
|
||||
id,
|
||||
});
|
||||
|
||||
export const authSetUpdates = (updates: Partial<IAuthState['updates']>) => ({
|
||||
type: AUTH_USER_ACTIONS.SET_UPDATES,
|
||||
updates,
|
||||
|
|
|
@ -14,7 +14,9 @@ export const AUTH_USER_ACTIONS = {
|
|||
LOAD_PROFILE: 'LOAD_PROFILE',
|
||||
SET_PROFILE: 'SET_PROFILE',
|
||||
GET_MESSAGES: 'GET_MESSAGES',
|
||||
|
||||
SEND_MESSAGE: 'SEND_MESSAGE',
|
||||
DELETE_MESSAGE: 'DELETE_MESSAGE',
|
||||
|
||||
SET_UPDATES: 'SET_UPDATES',
|
||||
SET_LAST_SEEN_MESSAGES: 'SET_LAST_SEEN_MESSAGES',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue