mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 23:04:21 +00:00
🔧 Count the owner of the group in its members
This commit is contained in:
parent
c1bf5978ac
commit
57f283ef74
3 changed files with 9 additions and 4 deletions
|
@ -15,6 +15,8 @@ export interface GroupJoinButtonProps {
|
|||
export function GroupJoinButton({resource}: GroupJoinButtonProps): JSX.Element | null {
|
||||
const authorization = useAuthorizationContext()
|
||||
|
||||
const trueMembers = [resource.value.owner, ...resource.value.members]
|
||||
|
||||
const doJoin =
|
||||
React.useCallback(
|
||||
async () => {
|
||||
|
@ -29,7 +31,7 @@ export function GroupJoinButton({resource}: GroupJoinButtonProps): JSX.Element |
|
|||
if(!authorization.state.user) {
|
||||
return null
|
||||
}
|
||||
if(resource.value.members.includes(authorization.state.user.id)) {
|
||||
if(trueMembers.includes(authorization.state.user.id)) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ export interface GroupLeaveButtonProps {
|
|||
export function GroupLeaveButton({resource}: GroupLeaveButtonProps): JSX.Element | null {
|
||||
const authorization = useAuthorizationContext()
|
||||
|
||||
const trueMembers = [resource.value.owner, ...resource.value.members]
|
||||
|
||||
const doLeave =
|
||||
React.useCallback(
|
||||
async () => {
|
||||
|
@ -29,7 +31,7 @@ export function GroupLeaveButton({resource}: GroupLeaveButtonProps): JSX.Element
|
|||
if(!authorization.state.user) {
|
||||
return null
|
||||
}
|
||||
if(!resource.value.members.includes(authorization.state.user.id)) {
|
||||
if(!trueMembers.includes(authorization.state.user.id)) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ export interface GroupResourcePanelProps {
|
|||
|
||||
export function GroupResourcePanel({resource}: GroupResourcePanelProps): JSX.Element {
|
||||
const icon = resource.value.access === "OPEN" ? faGlobe : faEnvelope
|
||||
const members = resource.value.members.length
|
||||
|
||||
const trueMembers = [resource.value.owner, ...resource.value.members]
|
||||
|
||||
return (
|
||||
<ResourcePanel>
|
||||
|
@ -29,7 +30,7 @@ export function GroupResourcePanel({resource}: GroupResourcePanelProps): JSX.Ele
|
|||
</Link>
|
||||
</ResourcePanel.Name>
|
||||
<ResourcePanel.Text>
|
||||
{members} member{members !== 1 ? "s" : ""}
|
||||
{trueMembers.length} member{trueMembers.length !== 1 ? "s" : ""}
|
||||
</ResourcePanel.Text>
|
||||
<ResourcePanel.Buttons>
|
||||
<GroupLeaveButton resource={resource}/>
|
||||
|
|
Loading…
Reference in a new issue