fix: usernames
This commit is contained in:
parent
7d342d4383
commit
9d52d98e8a
|
@ -25,7 +25,7 @@ export default function ChatSubmitMessage() {
|
|||
dispatch(submitMessage({
|
||||
channel,
|
||||
message,
|
||||
owner: 'r/anonymous' === channel ? user.id : 0,
|
||||
owner: '/r/anonymous' === channel ? 0 : user.id,
|
||||
timestamp: Date.now(),
|
||||
uuid: uuidv4(),
|
||||
}));
|
||||
|
|
7
src/client/store/effects.js
vendored
7
src/client/store/effects.js
vendored
|
@ -19,8 +19,11 @@ import {
|
|||
import {socket} from '~/client/hooks/useSocket';
|
||||
|
||||
const effects = {
|
||||
[join]: ({dispatch}, {payload: {users}}) => {
|
||||
dispatch(fetchUsernames(users));
|
||||
[join]: ({dispatch}, {payload: {messages, users}}) => {
|
||||
const ids = new Set();
|
||||
Object.values(messages).map((message) => message.owner).forEach((id) => ids.add(id));
|
||||
users.forEach((id) => ids.add(id));
|
||||
dispatch(fetchUsernames(Array.from(ids.keys())));
|
||||
},
|
||||
[joined]: ({dispatch}, {payload: {id}}) => {
|
||||
dispatch(fetchUsernames([id]));
|
||||
|
|
|
@ -75,11 +75,13 @@ const chatUsers = async (req) => {
|
|||
const entries = await Promise.all(
|
||||
toHydrate.map((channel) => channelState(req, joinChannel(channel))),
|
||||
);
|
||||
const chatUsers = [];
|
||||
const chatUsers = new Set();
|
||||
for (let i = 0; i < toHydrate.length; i++) {
|
||||
chatUsers.push(...entries[i].users);
|
||||
const {messages, users} = entries[i];
|
||||
Object.values(messages).map((message) => message.owner).forEach((id) => chatUsers.add(id));
|
||||
users.forEach((id) => chatUsers.add(id));
|
||||
}
|
||||
return chatUsers;
|
||||
return Array.from(chatUsers.keys());
|
||||
};
|
||||
|
||||
export const appChatState = async (req) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user