Chore: quick fix
This commit is contained in:
parent
d10e243ba3
commit
c03ac19f74
@ -89,13 +89,21 @@ export const CreatePage = () => {
|
|||||||
|
|
||||||
const addUser = (pubkey: string) => {
|
const addUser = (pubkey: string) => {
|
||||||
setUsers((prev) => {
|
setUsers((prev) => {
|
||||||
|
const signers = prev.filter((user) => user.role === UserRole.signer)
|
||||||
|
const viewers = prev.filter((user) => user.role === UserRole.viewer)
|
||||||
|
|
||||||
const existingUserIndex = prev.findIndex(
|
const existingUserIndex = prev.findIndex(
|
||||||
(user) => user.pubkey === pubkey
|
(user) => user.pubkey === pubkey
|
||||||
)
|
)
|
||||||
|
|
||||||
// add new
|
// add new
|
||||||
if (existingUserIndex === -1)
|
if (existingUserIndex === -1) {
|
||||||
return [...prev, { pubkey, role: userRole }]
|
if (userRole === UserRole.signer) {
|
||||||
|
return [...signers, { pubkey, role: userRole }, ...viewers]
|
||||||
|
} else {
|
||||||
|
return [...signers, ...viewers, { pubkey, role: userRole }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const existingUser = prev[existingUserIndex]
|
const existingUser = prev[existingUserIndex]
|
||||||
|
|
||||||
@ -108,7 +116,11 @@ export const CreatePage = () => {
|
|||||||
updatedUser.role = userRole
|
updatedUser.role = userRole
|
||||||
updatedUsers[existingUserIndex] = updatedUser
|
updatedUsers[existingUserIndex] = updatedUser
|
||||||
|
|
||||||
return updatedUsers
|
// signers should be placed at the start of the array
|
||||||
|
return [
|
||||||
|
...updatedUsers.filter((user) => user.role === UserRole.signer),
|
||||||
|
...updatedUsers.filter((user) => user.role === UserRole.viewer)
|
||||||
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,6 +539,7 @@ const DisplayUser = ({
|
|||||||
.filter((user) => user.role === UserRole.signer)
|
.filter((user) => user.role === UserRole.signer)
|
||||||
.map((user, index) => (
|
.map((user, index) => (
|
||||||
<SignerRow
|
<SignerRow
|
||||||
|
key={`signer-${index}`}
|
||||||
userMeta={metadata[user.pubkey]}
|
userMeta={metadata[user.pubkey]}
|
||||||
user={user}
|
user={user}
|
||||||
index={index}
|
index={index}
|
||||||
|
Loading…
Reference in New Issue
Block a user