Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 35x 35x 35x | import { DialogProps, List, ListItem } from "@mui/material"; import Avatar from "components/Avatar"; import Button from "components/Button"; import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner"; import { Dialog, DialogActions, DialogContent, DialogTitle, } from "components/Dialog"; import TextBody from "components/TextBody"; import { useLiteUsers } from "features/userQueries/useLiteUsers"; import { useTranslation } from "i18n"; import { GLOBAL, MESSAGES } from "i18n/namespaces"; import { LiteUser } from "proto/api_pb"; import { GroupChat } from "proto/conversations_pb"; import React from "react"; import makeStyles from "utils/makeStyles"; export const useMembersDialogStyles = makeStyles((theme) => ({ avatar: { height: 30, marginInlineEnd: theme.spacing(1), width: 30, }, memberListItemContainer: { alignItems: "center", display: "flex", justifyContent: "flex-start", }, })); function MemberListItem({ member, memberIsAdmin, }: { member: LiteUser.AsObject; memberIsAdmin: boolean; }) { const classes = useMembersDialogStyles(); return ( <ListItem dense className={classes.memberListItemContainer}> <Avatar user={member} className={classes.avatar} /> <TextBody noWrap> {member.name} {memberIsAdmin && " (admin)"} </TextBody> </ListItem> ); } export default function MembersDialog({ groupChat, ...props }: DialogProps & { groupChat?: GroupChat.AsObject }) { const { t } = useTranslation([GLOBAL, MESSAGES]); const members = useLiteUsers(groupChat?.memberUserIdsList ?? []); return ( <Dialog {...props} aria-labelledby="members-dialog-title"> <DialogTitle id="members-dialog-title"> {t("messages:members_dialog.title")} </DialogTitle> <DialogContent> <List> {members.isLoading ? ( <CenteredSpinner /> ) : ( Array.from(members.data?.values() ?? []).map((user) => user ? ( <MemberListItem key={`members-dialog-${user.userId}`} member={user} memberIsAdmin={ groupChat?.adminUserIdsList.includes(user.userId) ?? false } /> ) : null ) )} </List> </DialogContent> <DialogActions> <Button onClick={() => props.onClose ? props.onClose({}, "escapeKeyDown") : null } > {t("global:ok")} </Button> </DialogActions> </Dialog> ); } |