Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ const CONST = {
FNS_TIMEZONE_FORMAT_STRING: "yyyy-MM-dd'T'HH:mm:ssXXX",
FNS_DB_FORMAT_STRING: 'yyyy-MM-dd HH:mm:ss.SSS',
LONG_DATE_FORMAT_WITH_WEEKDAY: 'eeee, MMMM d, yyyy',
LONG_DATE_FORMAT_WITH_WEEKDAY_WITHOUT_YEAR: 'eeee, MMMM d',
ORDINAL_DAY_OF_MONTH: 'do',
MONTH_DAY_YEAR_ORDINAL_FORMAT: 'MMMM do, yyyy',
SECONDS_PER_DAY: 24 * 60 * 60,
Expand Down
33 changes: 5 additions & 28 deletions src/components/Search/SearchRouter/useAskConcierge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@ import useSidePanelReportID from '@hooks/useSidePanelReportID';

import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';

import {addAttachmentWithComment, addComment} from '@userActions/Report';
import {addComment} from '@userActions/Report';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {FileObject} from '@src/types/utils/Attachment';

/**
* Returns a callback that opens the side panel (or Concierge chat on native)
* and sends the provided search query as a message.
* Also returns a flag indicating whether the Ask Concierge item is ready to be displayed.
*
* @param forceConcierge Always target the Concierge report, ignoring the report the side panel currently maps to.
*/
function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} = {}) {
function useAskConcierge() {
const sidePanelReportID = useSidePanelReportID();
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const {openConciergeAnywhere, isInSidePanel} = useOpenConciergeAnywhere();
const targetReportID = !forceConcierge && isInSidePanel && sidePanelReportID ? sidePanelReportID : conciergeReportID;
const targetReportID = (isInSidePanel ? sidePanelReportID : undefined) ?? conciergeReportID;
const [targetReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetReportID)}`);
const {timezone, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
Expand All @@ -34,7 +31,7 @@ function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} =
if (!trimmedQuery || !shouldShowAskConcierge) {
return;
}
openConciergeAnywhere({forceConcierge});
openConciergeAnywhere();
addComment({
report: targetReport,
notifyReportID: targetReportID,
Expand All @@ -49,27 +46,7 @@ function useAskConcierge({forceConcierge = false}: {forceConcierge?: boolean} =
});
};

const askConciergeWithAttachment = (attachments: FileObject | FileObject[], searchQuery: string) => {
if (!shouldShowAskConcierge) {
return;
}
openConciergeAnywhere({forceConcierge});
addAttachmentWithComment({
report: targetReport,
notifyReportID: targetReportID,
ancestors: [],
attachments,
currentUserAccountID,
text: searchQuery.trim(),
timezone: timezone ?? CONST.DEFAULT_TIME_ZONE,
shouldPlaySound: true,
isInSidePanel,
delegateAccountID,
conciergeReportID,
});
};

return {askConcierge, askConciergeWithAttachment, shouldShowAskConcierge, conciergeTargetReportID: targetReportID};
return {askConcierge, shouldShowAskConcierge};
}

export default useAskConcierge;
17 changes: 1 addition & 16 deletions src/hooks/useConciergeSidePanelReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ function useConciergeSidePanelReportActions({
}
const filtered = actions.filter(isCurrentSessionAction);
if (filtered.length === 0) {
// Side panel: nothing matched the current session yet (e.g. just after reopen, before the new
// message propagates). Show the greeting instead of `actions` to avoid flashing stale history.
if (!isConciergeMainDM && conciergeGreetingAction) {
const createdAction = actions.find(isCreatedAction);
return createdAction ? [conciergeGreetingAction, createdAction] : [conciergeGreetingAction];
}
return actions;
Comment on lines 181 to 183

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep stale history hidden while a new message propagates

When a contextual Concierge side panel is reopened with hidden prior history and the user sends a new message, there is a window before the optimistic/server action reaches this list where filtered is empty. Returning the original actions in that window exposes all pre-session messages, causing the stale-history flash that the removed branch specifically prevented; return the greeting/created actions for non-main-DM side panels instead.

Useful? React with 👍 / 👎.

}
if (conciergeGreetingAction) {
Expand All @@ -194,16 +188,7 @@ function useConciergeSidePanelReportActions({
}
return filtered;
},
[
showConciergeSidePanelWelcome,
conciergeGreetingAction,
isConciergeHiddenHistory,
showFullHistory,
sessionStartTime,
isCurrentSessionAction,
hadUserMessageAtSessionStart,
isConciergeMainDM,
],
[showConciergeSidePanelWelcome, conciergeGreetingAction, isConciergeHiddenHistory, showFullHistory, sessionStartTime, isCurrentSessionAction, hadUserMessageAtSessionStart],
);

const filteredVisibleActions = useMemo(() => filterActions(visibleReportActions), [filterActions, visibleReportActions]);
Expand Down
7 changes: 0 additions & 7 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Erstellen Sie eine oder ziehen Sie eine Quittung hierher',
},
insightsSection: {chartUnavailable: 'Diagramm nicht verfügbar', notEnoughData: 'Wir haben noch nicht genügend Daten, um dieses Diagramm auszufüllen'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Guten Morgen, ${name}.` : 'Guten Morgen.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Guten Tag, ${name}.` : 'Guten Tag.'),
goodEvening: ({name}: {name?: string}) => (name ? `Guten Abend, ${name}.` : 'Guten Abend.'),
inputPlaceholder: 'Bitten Sie Concierge, Ihre Ausgaben zu analysieren oder Unterstützung zu erhalten',
inputPlaceholderMobile: 'Stellen Sie Concierge eine Frage',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,13 +1177,6 @@ const translations: TranslationDeepObject<typeof en> = {
chartUnavailable: 'Το γράφημα δεν είναι διαθέσιμο',
notEnoughData: 'Δεν έχουμε ακόμη αρκετά δεδομένα για να συμπληρώσουμε αυτό το γράφημα',
},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Καλημέρα, ${name}.` : 'Καλημέρα.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Καλησπέρα σας, ${name}.` : 'Καλό απόγευμα.'),
goodEvening: ({name}: {name?: string}) => (name ? `Καλησπέρα, ${name}.` : 'Καλησπέρα.'),
inputPlaceholder: 'Ζητήστε από το Concierge να αναλύσει τα έξοδά σας ή να λάβετε υποστήριξη',
inputPlaceholderMobile: 'Ρωτήστε το Concierge οτιδήποτε',
},
},
allSettingsScreen: {
subscription: 'Συνδρομή',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1003,13 +1003,6 @@ const translations = {
},
homePage: {
forYou: 'For you',
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Good morning, ${name}.` : 'Good morning.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Good afternoon, ${name}.` : 'Good afternoon.'),
goodEvening: ({name}: {name?: string}) => (name ? `Good evening, ${name}.` : 'Good evening.'),
inputPlaceholder: 'Ask Concierge to analyze your expenses or get support',
inputPlaceholderMobile: 'Ask Concierge anything',
},
timeSensitiveSection: {
title: 'Time sensitive',
ctaFix: 'Fix',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Crea uno o arrastra un recibo aquí',
},
insightsSection: {chartUnavailable: 'Gráfico no disponible', notEnoughData: 'Todavía no tenemos suficientes datos para completar este gráfico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Buenos días, ${name}.` : 'Buenos días.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Buenas tardes, ${name}.` : 'Buenas tardes.'),
goodEvening: ({name}: {name?: string}) => (name ? `Buenas noches, ${name}.` : 'Buenas noches.'),
inputPlaceholder: 'Pídele a Concierge que analice tus gastos o que te ayude',
inputPlaceholderMobile: 'Pregunta a Concierge cualquier cosa',
},
},
allSettingsScreen: {
subscription: 'Suscripcion',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,13 +1132,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Créez-en un ou faites glisser un reçu ici',
},
insightsSection: {chartUnavailable: 'Graphique indisponible', notEnoughData: 'Nous n’avons pas encore suffisamment de données pour remplir ce graphique'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Bonjour, ${name}.` : 'Bonjour.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Bonjour, ${name}.` : 'Bon après-midi.'),
goodEvening: ({name}: {name?: string}) => (name ? `Bonsoir, ${name}.` : 'Bonsoir.'),
inputPlaceholder: 'Demander à Concierge d’analyser vos dépenses ou d’obtenir de l’aide',
inputPlaceholderMobile: 'Demander n’importe quoi à Concierge',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1130,13 +1130,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Creane una o trascina qui una ricevuta',
},
insightsSection: {chartUnavailable: 'Grafico non disponibile', notEnoughData: 'Non abbiamo ancora abbastanza dati per compilare questo grafico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Buongiorno, ${name}.` : 'Buongiorno.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Buon pomeriggio, ${name}.` : 'Buon pomeriggio.'),
goodEvening: ({name}: {name?: string}) => (name ? `Buonasera, ${name}.` : 'Buona sera.'),
inputPlaceholder: 'Chiedi a Concierge di analizzare le tue spese o chiedi supporto',
inputPlaceholderMobile: 'Chiedi qualsiasi cosa a Concierge',
},
},
allSettingsScreen: {
subscription: 'Abbonamento',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: '新規作成するか、レシートをここにドラッグしてください',
},
insightsSection: {chartUnavailable: 'グラフを表示できません', notEnoughData: 'このチャートを表示するためのデータがまだ十分にありません'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `${name}さん、おはようございます。` : 'おはようございます。'),
goodAfternoon: ({name}: {name?: string}) => (name ? `${name}さん、こんにちは。` : 'こんにちは。'),
goodEvening: ({name}: {name?: string}) => (name ? `${name}さん、こんばんは。` : 'こんばんは。'),
inputPlaceholder: 'Concierge に経費の分析を依頼するか、サポートを受けます',
inputPlaceholderMobile: 'Concierge に何でも聞いてください',
},
},
allSettingsScreen: {
subscription: 'サブスクリプション',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Maak er een aan of sleep hier een bonnetje naartoe',
},
insightsSection: {chartUnavailable: 'Diagram niet beschikbaar', notEnoughData: 'We hebben nog niet genoeg gegevens om deze grafiek te vullen'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Goedemorgen, ${name}.` : 'Goedemorgen.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Goedemiddag, ${name}.` : 'Goedemiddag.'),
goodEvening: ({name}: {name?: string}) => (name ? `Goedenavond, ${name}.` : 'Goedenavond.'),
inputPlaceholder: 'Vraag Concierge om je uitgaven te analyseren of om hulp te krijgen',
inputPlaceholderMobile: 'Stel Concierge alles gerust een vraag',
},
},
allSettingsScreen: {
subscription: 'Abonnement',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,13 +1144,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Utwórz jeden lub przeciągnij tu paragon',
},
insightsSection: {chartUnavailable: 'Wykres niedostępny', notEnoughData: 'Nie mamy jeszcze wystarczającej ilości danych, żeby wypełnić ten wykres'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Dzień dobry, ${name}.` : 'Dzień dobry.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Dzień dobry, ${name}.` : 'Dzień dobry.'),
goodEvening: ({name}: {name?: string}) => (name ? `Dobry wieczór, ${name}.` : 'Dobry wieczór.'),
inputPlaceholder: 'Poproś Concierge o przeanalizowanie swoich wydatków lub uzyskaj pomoc',
inputPlaceholderMobile: 'Zapytaj Concierge o cokolwiek',
},
},
allSettingsScreen: {
subscription: 'Subskrypcja',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,13 +1128,6 @@ const translations: TranslationDeepObject<typeof en> = {
emptyStateMessage: 'Crie um ou arraste um recibo aqui',
},
insightsSection: {chartUnavailable: 'Gráfico indisponível', notEnoughData: 'Ainda não temos dados suficientes para preencher este gráfico'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `Bom dia, ${name}.` : 'Bom dia.'),
goodAfternoon: ({name}: {name?: string}) => (name ? `Boa tarde, ${name}.` : 'Boa tarde.'),
goodEvening: ({name}: {name?: string}) => (name ? `Boa noite, ${name}.` : 'Boa noite.'),
inputPlaceholder: 'Peça ao Concierge para analisar suas despesas ou obter suporte',
inputPlaceholderMobile: 'Pergunte qualquer coisa ao Concierge',
},
},
allSettingsScreen: {
subscription: 'Assinatura',
Expand Down
7 changes: 0 additions & 7 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,13 +1078,6 @@ const translations: TranslationDeepObject<typeof en> = {
seeMore: ({count}: {count: number}) => `再查看 ${count} 个`,
recentlyAddedSection: {title: '最近添加', viewAll: '查看所有报销费用', emptyStateTitle: '最近没有报销记录', emptyStateMessage: '创建一个或将收据拖到这里'},
insightsSection: {chartUnavailable: '图表不可用', notEnoughData: '我们目前没有足够的数据来填充此图表'},
conciergePrompt: {
goodMorning: ({name}: {name?: string}) => (name ? `早上好,${name}。` : '早上好。'),
goodAfternoon: ({name}: {name?: string}) => (name ? `下午好,${name}。` : '下午好。'),
goodEvening: ({name}: {name?: string}) => (name ? `晚上好,${name}。` : '晚上好。'),
inputPlaceholder: '向 Concierge 请求分析你的报销或获取支持',
inputPlaceholderMobile: '向 Concierge 提问任何问题',
},
},
allSettingsScreen: {
subscription: '订阅',
Expand Down
26 changes: 0 additions & 26 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,30 +260,6 @@ function formatToLongDateWithWeekday(datetime: string | Date, dateFnsLocale: Dat
return format(new Date(datetime), CONST.DATE.LONG_DATE_FORMAT_WITH_WEEKDAY, {locale: dateFnsLocale});
}

/**
* Format date to a long date format with weekday but without the year
*
* @returns Sunday, July 9
*/
function formatToLongDateWithWeekdayWithoutYear(datetime: string | Date, dateFnsLocale: DateFnsLocale | undefined): string {
return format(new Date(datetime), CONST.DATE.LONG_DATE_FORMAT_WITH_WEEKDAY_WITHOUT_YEAR, {locale: dateFnsLocale});
}

/**
* Get the time-of-day greeting key based on the hour of the given (already timezone-adjusted) date.
* Ranges: morning 4am to 12pm, afternoon 12pm to 5pm, evening 5pm to 4am.
*/
function getTimeOfDayGreetingKey(date: Date): 'goodMorning' | 'goodAfternoon' | 'goodEvening' {
const hour = date.getHours();
if (hour >= 4 && hour < 12) {
return 'goodMorning';
}
if (hour >= 12 && hour < 17) {
return 'goodAfternoon';
}
return 'goodEvening';
}

/**
* Format date to a weekday format
*
Expand Down Expand Up @@ -1234,8 +1210,6 @@ const DateUtils = {
isDate,
formatToDayOfWeek,
formatToLongDateWithWeekday,
formatToLongDateWithWeekdayWithoutYear,
getTimeOfDayGreetingKey,
formatToLocalTime,
formatToReadableString,
getZoneAbbreviation,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/fileDownload/FileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ const normalizeFileObject = async (file: FileObject): Promise<FileObject> => {

const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID;
const isIOSNative = getPlatform() === CONST.PLATFORM.IOS;
const isNative = isAndroidNative || isIOSNative;
const isNativePlatform = isAndroidNative || isIOSNative;

if (!isNative || 'size' in file) {
if (!isNativePlatform || 'size' in file) {
return file;
}

Expand Down
Loading
Loading