using user cache only and relying on that instead of fetching users
This commit is contained in:
@@ -94,25 +94,9 @@ function ConversationRow({ conversation }: { conversation: Conversation }) {
|
|||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { getUser, selectedConversation, selectConversation } = useTerminal();
|
const { getUser, selectedConversation, selectConversation } = useTerminal();
|
||||||
|
|
||||||
const [conversationUsers, setConversationUsers] = useImmer<User[]>([]);
|
|
||||||
|
|
||||||
const rendersCount = useRendersCount();
|
const rendersCount = useRendersCount();
|
||||||
console.warn('RENDER COUNT | CONVERSATION LIST ROW | ', rendersCount);
|
console.warn('RENDER COUNT | CONVERSATION LIST ROW | ', rendersCount);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
const userPromises = conversation.memberIdsList
|
|
||||||
// .filter((memberId) => memberId !== user.uid)
|
|
||||||
.map(async (memberId) => await getUser(memberId));
|
|
||||||
|
|
||||||
const userSettled = await Promise.all(userPromises);
|
|
||||||
|
|
||||||
setConversationUsers(userSettled);
|
|
||||||
})();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}, [conversation.memberIdsList, getUser, user, setConversationUsers]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem key={`${conversation.id}-priorityConvoList`}>
|
<ListItem key={`${conversation.id}-priorityConvoList`}>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
@@ -129,13 +113,16 @@ function ConversationRow({ conversation }: { conversation: Conversation }) {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Box sx={{ ml: 1, mr: 'auto', color: 'GrayText' }}>
|
<Box sx={{ ml: 2, mr: 'auto', color: 'GrayText' }}>
|
||||||
<ConversationLabel users={conversationUsers} conversationName={conversation.name} />
|
<ConversationLabel
|
||||||
|
users={conversation.userCache ?? []}
|
||||||
|
conversationName={conversation.name}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<AvatarGroup variant={'rounded'}>
|
<AvatarGroup variant={'rounded'}>
|
||||||
{conversationUsers.map((conversationUser, index) => (
|
{conversation.userCache?.map((conversationUser, index) => (
|
||||||
<Avatar
|
<Avatar
|
||||||
key={`${conversation.id}-${conversationUser.uid}-convoIcon`}
|
key={`${conversation.id}-${conversationUser.uid}-convoIcon`}
|
||||||
alt={conversationUser?.displayName}
|
alt={conversationUser?.displayName}
|
||||||
|
|||||||
@@ -335,8 +335,8 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
|
|
||||||
const [isUserSpeaking, setIsUserSpeaking] = useState<boolean>(false);
|
const [isUserSpeaking, setIsUserSpeaking] = useState<boolean>(false);
|
||||||
|
|
||||||
const [userAudioStream, setUserAudioStream] = useState<MediaStream>(null);
|
const [userAudioStream, setUserAudioStream] = useState<MediaStream | null>(null);
|
||||||
const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder>(null);
|
const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(null);
|
||||||
|
|
||||||
// from the time of starting to speak to finally sent to everyone out there
|
// from the time of starting to speak to finally sent to everyone out there
|
||||||
// feeling to user that everyone is listening right now even though it's only recording
|
// feeling to user that everyone is listening right now even though it's only recording
|
||||||
@@ -414,7 +414,7 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userAudioStream) {
|
if (!userAudioStream || !mediaRecorder) {
|
||||||
enqueueSnackbar('Check your audio mic permissions in preferences!!', { variant: 'error' });
|
enqueueSnackbar('Check your audio mic permissions in preferences!!', { variant: 'error' });
|
||||||
|
|
||||||
handleAskForMicrophonePermissions();
|
handleAskForMicrophonePermissions();
|
||||||
|
|||||||
Reference in New Issue
Block a user