mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
Remove redundant lock
With the use of the reason modal there's not really much use for the lock since it's really difficult to accidentally double-click the buttons
This commit is contained in:
parent
b00d960a27
commit
fc34ba4a0e
1 changed files with 6 additions and 30 deletions
|
@ -13,7 +13,7 @@
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
import { use, useState } from "react"
|
import { use } from "react"
|
||||||
import Client from "@/api/client.ts"
|
import Client from "@/api/client.ts"
|
||||||
import { RoomStateStore } from "@/api/statestore"
|
import { RoomStateStore } from "@/api/statestore"
|
||||||
import { MemDBEvent, MemberEventContent, Membership } from "@/api/types"
|
import { MemDBEvent, MemberEventContent, Membership } from "@/api/types"
|
||||||
|
@ -32,7 +32,6 @@ interface UserModerationProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const UserModeration = ({ userID, client, member }: UserModerationProps) => {
|
const UserModeration = ({ userID, client, member }: UserModerationProps) => {
|
||||||
const [actionInProgress, setActionInProgress] = useState(false)
|
|
||||||
const roomCtx = use(RoomContext)
|
const roomCtx = use(RoomContext)
|
||||||
const openModal = use(ModalContext)
|
const openModal = use(ModalContext)
|
||||||
|
|
||||||
|
@ -48,16 +47,13 @@ const UserModeration = ({ userID, client, member }: UserModerationProps) => {
|
||||||
if (reason) {
|
if (reason) {
|
||||||
payload["reason"] = reason
|
payload["reason"] = reason
|
||||||
}
|
}
|
||||||
setActionInProgress(true)
|
|
||||||
client.rpc
|
client.rpc
|
||||||
.setState(roomCtx?.store.roomID, "m.room.member", userID, payload)
|
.setState(roomCtx?.store.roomID, "m.room.member", userID, payload)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.debug("Actioned", userID)
|
console.debug("Actioned", userID)
|
||||||
setActionInProgress(false)
|
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error("Failed to action", e)
|
console.error("Failed to action", e)
|
||||||
setActionInProgress(false)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -86,51 +82,31 @@ const UserModeration = ({ userID, client, member }: UserModerationProps) => {
|
||||||
<h4>Moderation</h4>
|
<h4>Moderation</h4>
|
||||||
<div className="moderation-actions">
|
<div className="moderation-actions">
|
||||||
{(["knock", "leave"].includes(membership) || !member) && (
|
{(["knock", "leave"].includes(membership) || !member) && (
|
||||||
<button
|
<button className="moderation-action invite" onClick={runAction("invite")}>
|
||||||
className="moderation-action invite"
|
|
||||||
onClick={runAction("invite")}
|
|
||||||
disabled={actionInProgress}
|
|
||||||
>
|
|
||||||
<PersonAdd />
|
<PersonAdd />
|
||||||
<span>{membership === "knock" ? "Accept request to join" : "Invite"}</span>
|
<span>{membership === "knock" ? "Accept request to join" : "Invite"}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{["knock", "invite"].includes(membership) && (
|
{["knock", "invite"].includes(membership) && (
|
||||||
<button
|
<button className="moderation-action dangerous" onClick={runAction("leave")}>
|
||||||
className="moderation-action dangerous"
|
|
||||||
onClick={runAction("leave")}
|
|
||||||
disabled={actionInProgress}
|
|
||||||
>
|
|
||||||
<PersonRemove />
|
<PersonRemove />
|
||||||
<span>{membership === "invite" ? "Revoke invitation" : "Reject join request"}</span>
|
<span>{membership === "invite" ? "Revoke invitation" : "Reject join request"}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{membership === "join" && (
|
{membership === "join" && (
|
||||||
<button
|
<button className="moderation-action dangerous" onClick={runAction("leave")}>
|
||||||
className="moderation-action dangerous"
|
|
||||||
onClick={runAction("leave")}
|
|
||||||
disabled={actionInProgress}
|
|
||||||
>
|
|
||||||
<PersonRemove />
|
<PersonRemove />
|
||||||
<span>Kick</span>
|
<span>Kick</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{membership !== "ban" && (
|
{membership !== "ban" && (
|
||||||
<button
|
<button className="moderation-action dangerous" onClick={runAction("ban")}>
|
||||||
className="moderation-action dangerous"
|
|
||||||
onClick={runAction("ban")}
|
|
||||||
disabled={actionInProgress}
|
|
||||||
>
|
|
||||||
<Gavel />
|
<Gavel />
|
||||||
<span>Ban</span>
|
<span>Ban</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{membership === "ban" && (
|
{membership === "ban" && (
|
||||||
<button
|
<button className="moderation-action invite" onClick={runAction("leave")}>
|
||||||
className="moderation-action invite"
|
|
||||||
onClick={runAction("leave")}
|
|
||||||
disabled={actionInProgress}
|
|
||||||
>
|
|
||||||
<Gavel />
|
<Gavel />
|
||||||
<span>Unban</span>
|
<span>Unban</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue