mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-12 13:36:43 +00:00
fix: use current user info when writing a comment
This commit is contained in:
parent
88efe1a33b
commit
e67047fa46
1 changed files with 5 additions and 3 deletions
|
|
@ -4,9 +4,10 @@ import {useParams, Link} from 'react-router-dom';
|
||||||
import Routes from '../constants/routes';
|
import Routes from '../constants/routes';
|
||||||
// Redux
|
// Redux
|
||||||
import {compose} from '@reduxjs/toolkit';
|
import {compose} from '@reduxjs/toolkit';
|
||||||
import {connect} from 'react-redux';
|
import {connect, useSelector} from 'react-redux';
|
||||||
import {firestoreConnect, WithFirestoreProps} from 'react-redux-firebase';
|
import {firestoreConnect, WithFirestoreProps} from 'react-redux-firebase';
|
||||||
import {RootState} from '../store';
|
import {RootState} from '../store';
|
||||||
|
import {selectProfile} from '../store/firebase';
|
||||||
import Collections from '../constants/collections';
|
import Collections from '../constants/collections';
|
||||||
// Typing
|
// Typing
|
||||||
import Post from '../models/Post';
|
import Post from '../models/Post';
|
||||||
|
|
@ -22,9 +23,10 @@ interface IProps extends WithFirestoreProps {
|
||||||
* Display a Post and the related comments. Shows a form to add a comment.
|
* Display a Post and the related comments. Shows a form to add a comment.
|
||||||
*/
|
*/
|
||||||
const PostPage: FC<IProps> = ({post, firestore}) => {
|
const PostPage: FC<IProps> = ({post, firestore}) => {
|
||||||
|
const {avatarUrl, displayName} = useSelector(selectProfile);
|
||||||
const newComment: Comment = {
|
const newComment: Comment = {
|
||||||
name: post.name ?? 'error',
|
name: displayName ?? 'error',
|
||||||
avatarUrl: post.avatarUrl ?? 'error',
|
avatarUrl: avatarUrl ?? 'error',
|
||||||
text: '',
|
text: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue