Fix territory context menu visible for anon (#877)
This commit is contained in:
parent
1ea28b748c
commit
9cb657ab9a
|
@ -82,29 +82,32 @@ export default function TerritoryHeader ({ sub }) {
|
|||
<div className='d-flex my-2 justify-content-end'>
|
||||
<Share path={`/~${sub.name}`} title={`~${sub.name} stacker news territory`} className='mx-1' />
|
||||
{me &&
|
||||
(Number(sub.userId) === Number(me?.id)
|
||||
? (
|
||||
<Link href={`/~${sub.name}/edit`} className='d-flex align-items-center'>
|
||||
<Button variant='outline-grey border-2 rounded py-0' size='sm'>edit territory</Button>
|
||||
</Link>)
|
||||
: (
|
||||
<Button
|
||||
variant='outline-grey border-2 py-0 rounded'
|
||||
size='sm'
|
||||
onClick={async () => {
|
||||
try {
|
||||
await toggleMuteSub({ variables: { name: sub.name } })
|
||||
} catch {
|
||||
toaster.danger(`failed to ${sub.meMuteSub ? 'join' : 'mute'} territory`)
|
||||
return
|
||||
}
|
||||
toaster.success(`${sub.meMuteSub ? 'joined' : 'muted'} territory`)
|
||||
}}
|
||||
>{sub.meMuteSub ? 'join' : 'mute'} territory
|
||||
</Button>))}
|
||||
<ActionDropdown>
|
||||
<ToggleSubSubscriptionDropdownItem sub={sub} />
|
||||
</ActionDropdown>
|
||||
<>
|
||||
{(Number(sub.userId) === Number(me?.id)
|
||||
? (
|
||||
<Link href={`/~${sub.name}/edit`} className='d-flex align-items-center'>
|
||||
<Button variant='outline-grey border-2 rounded py-0' size='sm'>edit territory</Button>
|
||||
</Link>)
|
||||
: (
|
||||
<Button
|
||||
variant='outline-grey border-2 py-0 rounded'
|
||||
size='sm'
|
||||
onClick={async () => {
|
||||
try {
|
||||
await toggleMuteSub({ variables: { name: sub.name } })
|
||||
} catch {
|
||||
toaster.danger(`failed to ${sub.meMuteSub ? 'join' : 'mute'} territory`)
|
||||
return
|
||||
}
|
||||
toaster.success(`${sub.meMuteSub ? 'joined' : 'muted'} territory`)
|
||||
}}
|
||||
>{sub.meMuteSub ? 'join' : 'mute'} territory
|
||||
</Button>)
|
||||
)}
|
||||
<ActionDropdown>
|
||||
<ToggleSubSubscriptionDropdownItem sub={sub} />
|
||||
</ActionDropdown>
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
|
Loading…
Reference in New Issue