Skip to content

Commit

Permalink
Display labels for unregistered users
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkabuki committed Sep 12, 2023
1 parent 30311e1 commit 460d808
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ export const BasicMessageComponent: React.FC<BasicMessageProps & FileActionsProp
cancelDownload,
unregisteredUsernameModalHandleOpen,
duplicatedUsernameModalHandleOpen,
userLabel = null,
// KACPER
// userLabel = null,
}) => {
const messageDisplayData = messages[0]

const userLabel = messageDisplayData?.isRegistered ? null : UserLabelType.UNREGISTERED

const infoMessage = messageDisplayData.type === 3 // 3 stands for MessageType.Info

// Grey out sender name if the first message hasn't been sent yet
Expand All @@ -183,8 +186,8 @@ export const BasicMessageComponent: React.FC<BasicMessageProps & FileActionsProp
className={classNames({
[classes.wrapper]: !infoMessage,
})}
onMouseOver={() => {}}
onMouseLeave={() => {}}
onMouseOver={() => { }}
onMouseLeave={() => { }}
>
<ListItemText
disableTypography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('publicChannelsSelectors', () => {
// Convert regular messages to displayable messages
const displayable: Record<string, DisplayableMessage> = {}
for (const message of Object.values(msgs)) {
displayable[message.id] = displayableMessage(message, msgsOwners[message.id])
displayable[message.id] = displayableMessage(message, msgsOwners[message.id], true)
}

// Get groups names
Expand Down Expand Up @@ -374,4 +374,4 @@ describe('publicChannelsSelectors', () => {
})
})

export {}
export { }
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ export const newestCurrentChannelMessage = createSelector(sortedCurrentChannelMe
export const displayableCurrentChannelMessages = createSelector(
sortedCurrentChannelMessages,
allUsers,
(messages, certificates) => {
(messages, users) => {
return messages.reduce((result: DisplayableMessage[], message: ChannelMessage) => {
const user = certificates[message.pubKey]
const user = users[message.pubKey]
if (user) {
result.push(displayableMessage(message, user.username))
// @ts-ignore
result.push(displayableMessage(message, user.username, user.isRegistered))
}
return result
}, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ChannelMessage, type DisplayableMessage } from '@quiet/types'
import { formatMessageDisplayDate } from './formatMessageDisplayDate'

export const displayableMessage = (message: ChannelMessage, nickname: string): DisplayableMessage => {
export const displayableMessage = (message: ChannelMessage, nickname: string, isRegistered: boolean): DisplayableMessage => {
const date = formatMessageDisplayDate(message.createdAt)
return {
id: message.id,
Expand All @@ -10,6 +10,7 @@ export const displayableMessage = (message: ChannelMessage, nickname: string): D
createdAt: message.createdAt,
date,
nickname,
isRegistered,
media: message.media,
}
}
1 change: 1 addition & 0 deletions packages/types/src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface DisplayableMessage {
date: string // displayable
nickname: string
media?: FileMetadata
isRegistered?: boolean
}

export type MessagesGroupsType = Record<string, DisplayableMessage[]>
Expand Down

0 comments on commit 460d808

Please sign in to comment.