Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add room name to the top of searched chats #50135

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c756e74
Added policy header to chats in search
zfurtak Sep 17, 2024
c0086bc
Added report name
zfurtak Sep 18, 2024
38ee190
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Oct 2, 2024
ec5d2fb
First part of refactor
zfurtak Oct 2, 2024
664ee13
Done refactoring functions
zfurtak Oct 3, 2024
2c36ccc
Style change
zfurtak Oct 3, 2024
1bac0f2
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Oct 3, 2024
0a8ef3e
Change props passing to getReportName
zfurtak Oct 3, 2024
7c1dae3
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Oct 3, 2024
47cceca
Adjusted to review
zfurtak Oct 7, 2024
06d6e65
Adjusted to review
zfurtak Oct 7, 2024
138b819
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Oct 7, 2024
df25e44
Merge main
zfurtak Oct 21, 2024
19a209d
Fixed checks
zfurtak Oct 21, 2024
1bf9696
Adjusted to comments
zfurtak Oct 24, 2024
0dbd2c0
Merge main
zfurtak Oct 24, 2024
c729073
Refactored getReimbursementQueuedActionMessage
zfurtak Oct 24, 2024
88cd372
Fixed ts issue
zfurtak Oct 24, 2024
86bfff4
Merge main
zfurtak Nov 7, 2024
43d884f
Merged main
zfurtak Dec 4, 2024
0d26962
Merged main
zfurtak Jan 10, 2025
472bf48
Fixing lint errors
zfurtak Jan 15, 2025
dfc5f0c
Fix
zfurtak Jan 15, 2025
4fcc57a
Revert change in package.json
zfurtak Jan 15, 2025
a5a2fac
Merge main
zfurtak Jan 15, 2025
c37dbc3
Merge branch 'main' into react-native-wallet-poc
zfurtak Jan 15, 2025
cda82b9
Fix types errors
zfurtak Jan 16, 2025
31955d9
Merge branch 'main' into react-native-wallet-poc
zfurtak Jan 16, 2025
bdfefdd
Fix last typescript errors
zfurtak Jan 16, 2025
3c26949
Quick fix
zfurtak Jan 16, 2025
a2c3c27
Merge main
zfurtak Jan 16, 2025
8ee8560
Adjust the getReportName mock
zfurtak Jan 16, 2025
7c6fb6d
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 23, 2025
4ab69a3
Adjust commit to review
zfurtak Jan 24, 2025
fbf7c9b
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 24, 2025
e782f98
Adjust to all review comments
zfurtak Jan 24, 2025
63a5d2b
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 24, 2025
3d379ff
Style fixes
zfurtak Jan 27, 2025
97896f6
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 27, 2025
337c5f2
Revert change in package.json
zfurtak Jan 29, 2025
06823ad
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 29, 2025
445ec88
Merge branch '@zfurtak/search-chat-header' of https://github.com/soft…
zfurtak Jan 29, 2025
dd09f4e
Revert change in package.json
zfurtak Jan 29, 2025
8543d9e
Revert change in package.json
zfurtak Jan 29, 2025
a4ba93c
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Jan 30, 2025
55c9e7e
Simplify name for thread
zfurtak Jan 31, 2025
a2c62e9
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Feb 4, 2025
f965014
Merge branch 'main' into @zfurtak/search-chat-header
zfurtak Feb 4, 2025
924afa6
Merge branch 'main' into @zfurtak/search-chat-header
blazejkustra Feb 4, 2025
1d86468
Change the commit back to what is supposed to be
blazejkustra Feb 4, 2025
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
90 changes: 53 additions & 37 deletions src/components/SelectionList/ChatListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import {AttachmentContext} from '@components/AttachmentContext';
import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
import MultipleAvatars from '@components/MultipleAvatars';
import {ShowContextMenuContext} from '@components/ShowContextMenuContext';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import TextWithTooltip from '@components/TextWithTooltip';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import ReportActionItemDate from '@pages/home/report/ReportActionItemDate';
import ReportActionItemFragment from '@pages/home/report/ReportActionItemFragment';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import BaseListItem from './BaseListItem';
import type {ChatListItemProps, ListItem, ReportActionListItemType} from './types';
Expand Down Expand Up @@ -54,7 +57,6 @@ function ChatListItem<TItem extends ListItem>({

const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
const hoveredBackgroundColor = styles.sidebarLinkHover?.backgroundColor ? styles.sidebarLinkHover.backgroundColor : theme.sidebar;

const mentionReportContextValue = useMemo(() => ({currentReportID: item?.reportID ?? '-1'}), [item.reportID]);

return (
Expand Down Expand Up @@ -83,43 +85,57 @@ function ChatListItem<TItem extends ListItem>({
<MentionReportContext.Provider value={mentionReportContextValue}>
<ShowContextMenuContext.Provider value={contextValue}>
<AttachmentContext.Provider value={attachmentContextValue}>
<MultipleAvatars
icons={icons}
shouldShowTooltip={showTooltip}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar),
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
<View style={[styles.flexShrink1, styles.mr1]}>
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={reportActionItem.formattedFrom}
style={[
styles.chatItemMessageHeaderSender,
isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText,
styles.sidebarLinkTextBold,
styles.pre,
]}
/>
</View>
<ReportActionItemDate created={reportActionItem.created ?? ''} />
<View style={styles.webViewStyles.tagStyles.ol}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mb2]}>
<Text style={styles.chatItemMessageHeaderPolicy}>In </Text>
<TextLink
fontSize={variables.fontSizeSmall}
onPress={() => onSelectRow(item)}
>
{/* {ReportUtils.getReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${item.reportID}`])} */}
Report test
</TextLink>
</View>
<View style={styles.chatItemMessage}>
{reportActionItem.message.map((fragment, index) => (
<ReportActionItemFragment
// eslint-disable-next-line react/no-array-index-key
key={`actionFragment-${reportActionItem.reportActionID}-${index}`}
fragment={fragment}
actionName={reportActionItem.actionName}
source=""
accountID={from.accountID}
isFragmentContainingDisplayName={index === 0}
/>
))}
<View style={styles.flexRow}>
<MultipleAvatars
icons={icons}
shouldShowTooltip={showTooltip}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar),
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
<View style={[styles.flexShrink1, styles.mr1]}>
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={reportActionItem.formattedFrom}
style={[
styles.chatItemMessageHeaderSender,
isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText,
styles.sidebarLinkTextBold,
styles.pre,
]}
/>
</View>
<ReportActionItemDate created={reportActionItem.created ?? ''} />
</View>
<View style={styles.chatItemMessage}>
{reportActionItem.message.map((fragment, index) => (
<ReportActionItemFragment
// eslint-disable-next-line react/no-array-index-key
key={`actionFragment-${reportActionItem.reportActionID}-${index}`}
fragment={fragment}
actionName={reportActionItem.actionName}
source=""
accountID={from.accountID}
isFragmentContainingDisplayName={index === 0}
/>
))}
</View>
</View>
</View>
</View>
</AttachmentContext.Provider>
Expand Down
9 changes: 5 additions & 4 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Onyx from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyTagLists, ReportAction} from '@src/types/onyx';
import type {PolicyTagLists, Report, ReportAction} from '@src/types/onyx';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import * as Localize from './Localize';
Expand Down Expand Up @@ -132,12 +132,13 @@ function getForDistanceRequest(newMerchant: string, oldMerchant: string, newAmou
* ModifiedExpense::getNewDotComment in Web-Expensify should match this.
* If we change this function be sure to update the backend as well.
*/
function getForReportAction(reportID: string | undefined, reportAction: OnyxEntry<ReportAction>): string {
function getForReportAction(reportID: string | undefined, reportAction: OnyxEntry<ReportAction>, reports?: OnyxCollection<Report>, propPolicyTags?: OnyxCollection<PolicyTagLists>): string {
if (!ReportActionsUtils.isModifiedExpenseAction(reportAction)) {
return '';
}
const reportActionOriginalMessage = ReportActionsUtils.getOriginalMessage(reportAction);
const policyID = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.policyID ?? '-1';
const report = (reports ?? ReportConnection.getAllReports())?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const policyID = report?.policyID ?? '-1';

const removalFragments: string[] = [];
const setFragments: string[] = [];
Expand Down Expand Up @@ -224,7 +225,7 @@ function getForReportAction(reportID: string | undefined, reportAction: OnyxEntr

const hasModifiedTag = isReportActionOriginalMessageAnObject && 'oldTag' in reportActionOriginalMessage && 'tag' in reportActionOriginalMessage;
if (hasModifiedTag) {
const policyTags = allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {};
const policyTags = (propPolicyTags ?? allPolicyTags)?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {};
const transactionTag = reportActionOriginalMessage?.tag ?? '';
const oldTransactionTag = reportActionOriginalMessage?.oldTag ?? '';
const splittedTag = TransactionUtils.getTagArrayFromName(transactionTag);
Expand Down
11 changes: 8 additions & 3 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails
* @param shouldChangeUserDisplayName - It will replace the current user's personal detail object's displayName with 'You'.
* @returns - Array of personal detail objects
*/
function getPersonalDetailsByIDs(accountIDs: number[], currentUserAccountID: number, shouldChangeUserDisplayName = false): PersonalDetails[] {
function getPersonalDetailsByIDs(
accountIDs: number[],
currentUserAccountID: number,
shouldChangeUserDisplayName = false,
personalDetailsProp?: Partial<PersonalDetailsList>,
): PersonalDetails[] {
const result: PersonalDetails[] = accountIDs
.filter((accountID) => !!allPersonalDetails?.[accountID])
.filter((accountID) => !!(personalDetailsProp ?? allPersonalDetails)?.[accountID])
.map((accountID) => {
const detail = (allPersonalDetails?.[accountID] ?? {}) as PersonalDetails;
const detail = ((personalDetailsProp ?? allPersonalDetails)?.[accountID] ?? {}) as PersonalDetails;

if (shouldChangeUserDisplayName && currentUserAccountID === detail.accountID) {
return {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {OnyxInputOrEntry, PrivatePersonalDetails} from '@src/types/onyx';
import type {OnyxInputOrEntry, PersonalDetailsList, PrivatePersonalDetails} from '@src/types/onyx';
import type {IssueNewCardOriginalMessage, JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage';
import type Report from '@src/types/onyx/Report';
import type ReportAction from '@src/types/onyx/ReportAction';
Expand Down Expand Up @@ -1728,9 +1728,9 @@ function isCardIssuedAction(reportAction: OnyxEntry<ReportAction>) {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, CONST.REPORT.ACTIONS.TYPE.CARD_MISSING_ADDRESS);
}

function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, shouldRenderHTML = false) {
function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, shouldRenderHTML = false, personalDetails?: Partial<PersonalDetailsList>) {
const assigneeAccountID = (getOriginalMessage(reportAction) as IssueNewCardOriginalMessage)?.assigneeAccountID;
const assigneeDetails = PersonalDetailsUtils.getPersonalDetailsByIDs([assigneeAccountID], currentUserAccountID ?? -1).at(0);
const assigneeDetails = PersonalDetailsUtils.getPersonalDetailsByIDs([assigneeAccountID], currentUserAccountID ?? -1, false, personalDetails).at(0);

const assignee = shouldRenderHTML ? `<mention-user accountID="${assigneeAccountID}"/>` : assigneeDetails?.firstName ?? assigneeDetails?.login ?? '';
const link = shouldRenderHTML
Expand Down
Loading
Loading