Skip to content

Commit

Permalink
update all LHN icons
Browse files Browse the repository at this point in the history
  • Loading branch information
grgia committed Jun 9, 2023
1 parent fbae916 commit 55e4f06
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ const OptionRowLHN = (props) => {
backgroundColor={props.isFocused ? themeColors.activeComponentBG : themeColors.sidebar}
mainAvatar={optionItem.icons[0]}
secondaryAvatar={optionItem.icons[1]}
mainTooltip={optionItem.ownerEmail}
secondaryTooltip={optionItem.subtitle}
mainTooltip={optionItem.icons[0].name}
secondaryTooltip={optionItem.icons[1].name}
size={props.viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
/>
) : (
Expand All @@ -160,7 +160,7 @@ const OptionRowLHN = (props) => {
props.isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !props.isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
shouldShowTooltip={!optionItem.isChatRoom && !optionItem.isArchivedRoom}
shouldShowTooltip={!optionItem.isArchivedRoom}
/>
))}
<View style={contentContainerStyles}>
Expand Down
12 changes: 6 additions & 6 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const defaultProps = {

const MultipleAvatars = (props) => {
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL ? [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall] : [styles.emptyAvatar, styles.emptyAvatarMargin];
const singleAvatarStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const singleAvatarStyle = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const secondAvatarStyles = [props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar, ...props.secondAvatarStyle];
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : [];

Expand Down Expand Up @@ -172,37 +172,37 @@ const MultipleAvatars = (props) => {
)}
</>
) : (
<View style={singleAvatarStyles}>
<View style={[singleAvatarStyle, props.icons[0].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[0].type) : {}]}>
<Tooltip text={tooltipTexts[0]}>
{/* View is necessary for tooltip to show for multiple avatars in LHN */}
<View>
<Avatar
source={props.icons[0].source || props.fallbackIcon}
fill={themeColors.iconSuccessFill}
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER}
imageStyles={[singleAvatarStyles]}
imageStyles={[singleAvatarStyle]}
name={props.icons[0].name}
type={props.icons[0].type}
/>
</View>
</Tooltip>
<View style={secondAvatarStyles}>
<View style={[[...secondAvatarStyles, props.icons[1].type === CONST.ICON_TYPE_WORKSPACE ? StyleUtils.getAvatarBorderRadius(props.size, props.icons[1].type) : {}]]}>
{props.icons.length === 2 ? (
<Tooltip text={tooltipTexts[1]}>
<View>
<Avatar
source={props.icons[1].source || props.fallbackIcon}
fill={themeColors.iconSuccessFill}
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER}
imageStyles={[singleAvatarStyles]}
imageStyles={[singleAvatarStyle]}
name={props.icons[1].name}
type={props.icons[1].type}
/>
</View>
</Tooltip>
) : (
<Tooltip text={tooltipTexts.slice(1).join(', ')}>
<View style={[singleAvatarStyles, styles.alignItemsCenter, styles.justifyContentCenter]}>
<View style={[singleAvatarStyle, styles.alignItemsCenter, styles.justifyContentCenter]}>
<Text
selectable={false}
style={props.size === CONST.AVATAR_SIZE.SMALL ? styles.avatarInnerTextSmall : styles.avatarInnerText}
Expand Down
56 changes: 29 additions & 27 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,24 @@ function isThread(report) {
return Boolean(report && report.parentReportID && report.parentReportActionID && report.type === CONST.REPORT.TYPE.CHAT);
}

/**
* Returns true if report is a DM/Group DM chat.
*
* @param {Object} report
* @returns {Boolean}
*/
function isDM(report) {
return Boolean(!getChatType(report));
}

/**
* If the report has a chat type, it is a workspace chat.
* If the report is a thread and has a chat type set, it is a workspace chat.
*
* @param {Object} report
* @returns {Boolean}
*/
function isWorkspaceThread(report) {
return Boolean(isThread(report) && getChatType(report));
return Boolean(isThread(report) && !isDM(report));
}

/**
Expand Down Expand Up @@ -771,13 +780,13 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false)
type: CONST.ICON_TYPE_AVATAR,
name: '',
};

if (_.isEmpty(report)) {
result.source = defaultIcon || Expensicons.FallbackAvatar;
return [result];
}
if (isConciergeChatReport(report)) {
result.source = CONST.CONCIERGE_ICON_URL;
result.name = CONST.EMAIL.CONCIERGE;
return [result];
}
if (isThread(report)) {
Expand Down Expand Up @@ -813,34 +822,27 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false)
}
if (isPolicyExpenseChat(report) || isExpenseReport(report)) {
const workspaceIcon = getWorkspaceIcon(report);
const adminIcon = {
const memberIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.ownerEmail, 'avatar']), report.ownerEmail),
name: report.ownerEmail,
type: CONST.ICON_TYPE_AVATAR,
};

// Return the workspace avatar if the user is the owner of the policy expense chat
if (report.isOwnPolicyExpenseChat && !isExpenseReport(report)) {
return [workspaceIcon, adminIcon];
}

// if (isExpenseReport(report)) {
// return [adminIcon, workspaceIcon]
// }

// If the user is an admin, return avatar source of the other participant of the report
// (their workspace chat) and the avatar source of the workspace
return [adminIcon, workspaceIcon];
return isExpenseReport(report) ? [memberIcon, workspaceIcon] : [workspaceIcon, memberIcon];
}
if (isIOUReport(report)) {
const email = isPayer ? report.managerEmail : report.ownerEmail;
return [
{
source: UserUtils.getAvatar(lodashGet(personalDetails, [email, 'avatar']), email),
name: email,
type: CONST.ICON_TYPE_AVATAR,
},
];
const managerIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.managerEmail, 'avatar']), report.managerEmail),
name: report.managerEmail,
type: CONST.ICON_TYPE_AVATAR,
};

const ownerIcon = {
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.ownerEmail, 'avatar']), report.ownerEmail),
name: report.ownerEmail,
type: CONST.ICON_TYPE_AVATAR,
};

return isPayer ? [managerIcon, ownerIcon] : [ownerIcon, managerIcon];
}

return getIconsForParticipants(report.participants, personalDetails);
Expand Down Expand Up @@ -2135,7 +2137,7 @@ function getWhisperDisplayNames(participants) {
}

/**
* Show subscript on IOU or expense report
* Show subscript on workspace chats and workspace threads and expense requests
* @param {Object} report
* @returns {Boolean}
*/
Expand All @@ -2152,7 +2154,7 @@ function shouldReportShowSubscript(report) {
return true;
}

return isExpenseReport(report);
return false;
}

/**
Expand Down

0 comments on commit 55e4f06

Please sign in to comment.