pop that shit
This commit is contained in:
@@ -92,6 +92,7 @@ export default function ConversationDetails() {
|
|||||||
<ConversationLabel
|
<ConversationLabel
|
||||||
users={selectedConversation.userCache ?? []}
|
users={selectedConversation.userCache ?? []}
|
||||||
conversationName={selectedConversation.name}
|
conversationName={selectedConversation.name}
|
||||||
|
isSelected={true}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ function ConversationRow({ conversation }: { conversation: Conversation }) {
|
|||||||
<ConversationLabel
|
<ConversationLabel
|
||||||
users={conversation.userCache ?? []}
|
users={conversation.userCache ?? []}
|
||||||
conversationName={conversation.name}
|
conversationName={conversation.name}
|
||||||
|
isSelected={selectedConversation?.id === conversation.id}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import { User } from '@nirvana/core/src/models/user.model';
|
|||||||
import useAuth from '../providers/AuthProvider';
|
import useAuth from '../providers/AuthProvider';
|
||||||
import UserDetailRow from '../subcomponents/UserDetailRow';
|
import UserDetailRow from '../subcomponents/UserDetailRow';
|
||||||
import CircularProgress from '@mui/material/CircularProgress';
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
|
import { NirvanaRules } from '../util/rules';
|
||||||
|
|
||||||
export default function NewConversationDialog({
|
export default function NewConversationDialog({
|
||||||
open,
|
open,
|
||||||
@@ -106,7 +107,12 @@ export default function NewConversationDialog({
|
|||||||
|
|
||||||
const handleSubmitLocal = useCallback(async () => {
|
const handleSubmitLocal = useCallback(async () => {
|
||||||
if (selectedUsers.length === 0) {
|
if (selectedUsers.length === 0) {
|
||||||
enqueueSnackbar('Must a person!', { variant: 'error' });
|
enqueueSnackbar('Must select a person!', { variant: 'error' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedUsers.length + 1 >= NirvanaRules.maxMembersPerConversation) {
|
||||||
|
enqueueSnackbar('A group can only have 8 people including you!', { variant: 'error' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { User } from '@nirvana/core/src/models/user.model';
|
|||||||
import { Typography } from '@mui/material';
|
import { Typography } from '@mui/material';
|
||||||
import useAuth from '../providers/AuthProvider';
|
import useAuth from '../providers/AuthProvider';
|
||||||
|
|
||||||
type IConversationLabel =
|
type IConversationLabel = (
|
||||||
| {
|
| {
|
||||||
conversationName?: string;
|
conversationName?: string;
|
||||||
users: User[];
|
users: User[];
|
||||||
@@ -13,18 +13,28 @@ type IConversationLabel =
|
|||||||
| {
|
| {
|
||||||
conversationName: string;
|
conversationName: string;
|
||||||
users?: User[];
|
users?: User[];
|
||||||
};
|
}
|
||||||
|
) & { isSelected?: boolean };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if there is a name in the conversation, then return that
|
* if there is a name in the conversation, then return that
|
||||||
* if not, then return first three names
|
* if not, then return first three names
|
||||||
*/
|
*/
|
||||||
export default function ConversationLabel({ conversationName, users }: IConversationLabel) {
|
export default function ConversationLabel({
|
||||||
|
conversationName,
|
||||||
|
users,
|
||||||
|
isSelected = false,
|
||||||
|
}: IConversationLabel) {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
|
|
||||||
if (conversationName) {
|
if (conversationName) {
|
||||||
return (
|
return (
|
||||||
<Typography noWrap variant="overline">
|
<Typography
|
||||||
|
noWrap
|
||||||
|
variant={'overline'}
|
||||||
|
color={isSelected && 'primary'}
|
||||||
|
sx={{ fontWeight: isSelected && 'bold' }}
|
||||||
|
>
|
||||||
{conversationName}
|
{conversationName}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
@@ -36,7 +46,12 @@ export default function ConversationLabel({ conversationName, users }: IConversa
|
|||||||
const firstName = filteredUsers[0].displayName.split(' ')[0];
|
const firstName = filteredUsers[0].displayName.split(' ')[0];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography noWrap variant="overline">
|
<Typography
|
||||||
|
noWrap
|
||||||
|
variant={'overline'}
|
||||||
|
color={isSelected && 'primary'}
|
||||||
|
sx={{ fontWeight: isSelected && 'bold' }}
|
||||||
|
>
|
||||||
{firstName}
|
{firstName}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
@@ -48,7 +63,12 @@ export default function ConversationLabel({ conversationName, users }: IConversa
|
|||||||
const formattedFirstnames = firstNames.slice(0, -1).join(',') + ' and ' + firstNames.slice(-1);
|
const formattedFirstnames = firstNames.slice(0, -1).join(',') + ' and ' + firstNames.slice(-1);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Typography noWrap variant="overline">
|
<Typography
|
||||||
|
noWrap
|
||||||
|
variant={'overline'}
|
||||||
|
color={isSelected && 'primary'}
|
||||||
|
sx={{ fontWeight: isSelected && 'bold' }}
|
||||||
|
>
|
||||||
{formattedFirstnames}
|
{formattedFirstnames}
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// the rules of the game
|
||||||
|
|
||||||
|
export const NirvanaRules = {
|
||||||
|
maxMembersPerConversation: 8,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user