Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/irc-display-nickname.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"fuelrats.com": minor
---

Add ability to set IRC display nickname in user profile

- Users can now select which of their registered IRC nicknames should be their display nickname
- Added a star icon button next to each non-display nickname to set it as the display nickname
- The current display nickname is indicated by the absence of action buttons
63 changes: 47 additions & 16 deletions src/components/UserNicknamesPanel/UserNicknamesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useDispatch, useSelector } from 'react-redux'
import ConfirmActionButton from '~/components/ConfirmActionButton'
import AddNicknameForm from '~/components/Forms/AddNicknameForm/AddNicknameForm'
import MessageBox from '~/components/MessageBox'
import { deleteNickname } from '~/store/actions/user'
import { deleteNickname, setDisplayNickname, getUserProfile } from '~/store/actions/user'
import {
selectUserById,
withCurrentUserId,
Expand Down Expand Up @@ -57,6 +57,19 @@ function UserNicknamesPanel () {
return undefined
}, [dispatch, nicknames, user])

const handleSetDisplayNickname = useCallback(async (event) => {
const nickname = nicknames.find((nick) => {
return nick.id === event.target.name
})

const response = await dispatch(setDisplayNickname(nickname.id, nickname.attributes.nick))

if (!isError(response)) {
// Refresh user profile to get updated nicknames
await dispatch(getUserProfile())
}
}, [dispatch, nicknames])

const nickCount = nicknames?.length
const maxNicksReached = (nickCount >= MAX_NICKS)

Expand All @@ -83,24 +96,42 @@ function UserNicknamesPanel () {
}
{
nicknames?.map((nickname) => {
const isDisplayNick = nickname.attributes?.display === nickname.attributes?.nick
return (
<li key={nickname.id}>
<span>{nickname.attributes?.nick}</span>
{
// Only render for additional nicks, prevent for display nick.
nickname.attributes?.display !== nickname.attributes?.nick && (
<ConfirmActionButton
className="icon"
confirmButtonText={`Delete nickname '${nickname.attributes?.nick}'`}
confirmSubText=""
denyButtonText="Cancel"
name={nickname.id}
onConfirm={handleDeleteNickname}
onConfirmText="">
<FontAwesomeIcon fixedWidth icon="trash" />
</ConfirmActionButton>
)
}
<div>
{
// Only show set display button for non-display nicks
!isDisplayNick && (
<ConfirmActionButton
className="icon"
confirmButtonText={`Set '${nickname.attributes?.nick}' as display nickname`}
confirmSubText=""
denyButtonText="Cancel"
name={nickname.id}
onConfirm={handleSetDisplayNickname}
onConfirmText="">
<FontAwesomeIcon fixedWidth icon="star" />
</ConfirmActionButton>
)
}
{
// Only render for additional nicks, prevent for display nick.
!isDisplayNick && (
<ConfirmActionButton
className="icon"
confirmButtonText={`Delete nickname '${nickname.attributes?.nick}'`}
confirmSubText=""
denyButtonText="Cancel"
name={nickname.id}
onConfirm={handleDeleteNickname}
onConfirmText="">
<FontAwesomeIcon fixedWidth icon="trash" />
</ConfirmActionButton>
)
}
</div>
</li>
)
}) ?? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
span {
word-break: break-word;
}

div {
display: flex;
gap: 0.5rem;
}
}

.addNicknameFloat {
Expand Down
1 change: 1 addition & 0 deletions src/store/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const nicknames = {
read: 'nicknames/read',
create: 'nicknames/create',
delete: 'nicknames/delete',
setDisplay: 'nicknames/setDisplay',
}


Expand Down
11 changes: 11 additions & 0 deletions src/store/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,14 @@ export const changeEmail = ({ id, ...data }) => {
},
)
}

export const setDisplayNickname = (nicknameId, displayNick) => {
return frApiRequest(
actionTypes.nicknames.setDisplay,
{
url: `/nicknames/${nicknameId}/display`,
method: 'put',
data: createRequestBody('nicknames', { displayNick }),
},
)
}
1 change: 1 addition & 0 deletions src/util/fontawesome/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export {
faSignature,
faSpaceShuttle,
faSpinner,
faStar,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to provide the regular version, since this only provides the solid version. Sorry I forgot we don't actually have this icon pack in here yet. without adding it the icon won't load properly.

Screenshot 2025-09-07 at 11 01 08

To fix:

  1. run yarn add "@fortawesome/free-regular-svg-icons@^5.15.4"
  2. add export to library.js
export {
  faStar as farStar,
} from '@fortawesome/free-regular-svg-icons'

faSync,
faTimes,
faTimesCircle,
Expand Down