fix: user actions
This commit is contained in:
parent
e2eb517687
commit
c1c3bed5f5
|
@ -4,6 +4,7 @@ import React from 'react';
|
|||
import {useSelector} from 'react-redux';
|
||||
|
||||
import {channelUsersSelector} from '~/common/state/chat';
|
||||
import {redditUsernameSelector} from '~/common/state/user';
|
||||
import {usernamesSelector} from '~/common/state/usernames';
|
||||
|
||||
import useChannel from '~/client/hooks/useChannel';
|
||||
|
@ -13,43 +14,51 @@ import Channel from './channel';
|
|||
export default function ChatRightUsers() {
|
||||
const channel = useChannel();
|
||||
const ids = useSelector((state) => channelUsersSelector(state, channel));
|
||||
const redditUsername = useSelector(redditUsernameSelector);
|
||||
const usernames = useSelector(usernamesSelector);
|
||||
const list = ids.map((id) => usernames[id]).sort();
|
||||
const usersActions = [
|
||||
{
|
||||
icon: '❤️',
|
||||
label: 'Favorite',
|
||||
onClick: () => {},
|
||||
},
|
||||
{
|
||||
icon: '🚫',
|
||||
label: 'Unfriend',
|
||||
onClick: () => {},
|
||||
},
|
||||
{
|
||||
icon: '☢️',
|
||||
label: 'Block',
|
||||
onClick: () => {},
|
||||
},
|
||||
];
|
||||
return (
|
||||
<div
|
||||
className="chat--rightUsers"
|
||||
>
|
||||
<h2 className="users__chatsTitle">Who's here</h2>
|
||||
<ul className="users__chatsList">
|
||||
{list.map((username) => (
|
||||
{list.map((username) => {
|
||||
const isLinked = (
|
||||
redditUsername !== username
|
||||
&& '/r/anonymous' !== channel
|
||||
);
|
||||
const userActions = [];
|
||||
if (isLinked) {
|
||||
userActions.push({
|
||||
icon: '➕',
|
||||
label: 'Add friend',
|
||||
onClick: () => {},
|
||||
});
|
||||
userActions.push({
|
||||
icon: '☢️',
|
||||
label: 'Block',
|
||||
onClick: () => {},
|
||||
});
|
||||
}
|
||||
// {
|
||||
// icon: '❤️',
|
||||
// label: 'Favorite',
|
||||
// onClick: () => {},
|
||||
// },
|
||||
return (
|
||||
<li
|
||||
className="users__item"
|
||||
>
|
||||
<Channel
|
||||
actions={usersActions}
|
||||
href={`/chat/u/${username}`}
|
||||
actions={userActions}
|
||||
href={isLinked ? `/chat/u/${username}` : null}
|
||||
name={username}
|
||||
prefix="/u/"
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -45,6 +45,11 @@ export const activeFriendshipSelector = createSelector(
|
|||
(friendship) => Object.values(friendship).filter(({state}) => 'active' === state),
|
||||
);
|
||||
|
||||
export const isAnonymousSelector = createSelector(
|
||||
[userSelector],
|
||||
({isAnonymous}) => isAnonymous,
|
||||
);
|
||||
|
||||
export const pendingFriendshipSelector = createSelector(
|
||||
friendshipSelector,
|
||||
(friendship) => Object.values(friendship).filter(({state}) => 'pending' === state),
|
||||
|
|
Loading…
Reference in New Issue
Block a user