Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/0xmiroslav/Expensify into f…
Browse files Browse the repository at this point in the history
…ix/18744-auto-suggester
  • Loading branch information
0xmiroslav committed May 15, 2023
2 parents 9302982 + 3deeed9 commit 02bce91
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 33 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- name: Load shell utils
run: source ./scripts/shellUtils.sh

- uses: Expensify/App/.github/actions/composite/setupNode@main

- name: Lint JavaScript with ESLint
Expand All @@ -31,6 +28,6 @@ jobs:
npm run prettier -- --loglevel silent
if ! git diff --name-only --exit-code; then
# shellcheck disable=SC2016
error 'Error: Prettier diff detected! Please run `npm run prettier` and commit the changes.'
echo 'Error: Prettier diff detected! Please run `npm run prettier` and commit the changes.'
exit 1
fi
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001031404
versionName "1.3.14-4"
versionCode 1001031405
versionName "1.3.14-5"
}

splits {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3.14.4</string>
<string>1.3.14.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.14.4</string>
<string>1.3.14.5</string>
</dict>
</plist>
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.14-4",
"version": "1.3.14-5",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down Expand Up @@ -75,7 +75,7 @@
"babel-polyfill": "^6.26.0",
"dom-serializer": "^0.2.2",
"domhandler": "^4.3.0",
"expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#5f4672c84e19122fc77b4bf1ac092d4919472112",
"expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#e7e765d47eeafbeac588bbf88044d91bf680437d",
"fbjs": "^3.0.2",
"html-entities": "^1.3.1",
"htmlparser2": "^7.2.0",
Expand Down
6 changes: 1 addition & 5 deletions src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,7 @@ function MagicCodeInput(props) {
key={index}
style={[styles.w15]}
>
<View style={[
styles.textInputContainer,
focusedIndex === index ? styles.borderColorFocus : {},
props.hasError || props.errorText ? styles.borderColorDanger : {},
]}>
<View style={[styles.textInputContainer, focusedIndex === index ? styles.borderColorFocus : {}, props.hasError || props.errorText ? styles.borderColorDanger : {}]}>
<Text style={[styles.magicCodeInput, styles.textAlignCenter]}>{decomposeString(props.value)[index] || ''}</Text>
</View>
<View style={[StyleSheet.absoluteFillObject, styles.w100, styles.opacity0]}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class OptionRow extends Component {
tooltipEnabled={this.props.showTitleTooltip}
numberOfLines={1}
textStyles={displayNameStyle}
shouldUseFullTitle={this.props.option.isChatRoom || this.props.option.isPolicyExpenseChat}
shouldUseFullTitle={this.props.option.isChatRoom || this.props.option.isPolicyExpenseChat || this.props.option.isMoneyRequestReport}
/>
{this.props.option.alternateText ? (
<Text
Expand Down
3 changes: 2 additions & 1 deletion src/libs/CurrencyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function isCurrencySymbolLTR(currencyCode) {
*/
function convertToSmallestUnit(currency, amountAsFloat) {
const currencyUnit = getCurrencyUnit(currency);
return Math.trunc(amountAsFloat * currencyUnit);
// We round off the number to resolve floating-point precision issues.
return Math.round(amountAsFloat * currencyUnit);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ function createOption(logins, personalDetails, report, reportActions = {}, {show
result.isDefaultRoom = ReportUtils.isDefaultRoom(report);
result.isArchivedRoom = ReportUtils.isArchivedRoom(report);
result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
result.isThread = ReportUtils.isThread(report);
result.shouldShowSubscript = result.isPolicyExpenseChat && !report.isOwnPolicyExpenseChat && !result.isArchivedRoom;
result.allReportErrors = getAllReportErrors(report, reportActions);
Expand All @@ -430,7 +431,7 @@ function createOption(logins, personalDetails, report, reportActions = {}, {show
if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml})) {
lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`;
} else {
lastMessageTextFromReport = report ? report.lastMessageText : '';
lastMessageTextFromReport = report ? report.lastMessageText || '' : '';
}

const lastActorDetails = personalDetailMap[report.lastActorEmail] || null;
Expand All @@ -449,6 +450,8 @@ function createOption(logins, personalDetails, report, reportActions = {}, {show

if (result.isChatRoom || result.isPolicyExpenseChat) {
result.alternateText = showChatPreviewLine && !forcePolicyNamePreview && lastMessageText ? lastMessageText : subtitle;
} else if (result.isMoneyRequestReport) {
result.alternateText = lastMessageTextFromReport.length > 0 ? lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet');
} else {
result.alternateText = showChatPreviewLine && lastMessageText ? lastMessageText : LocalePhoneNumber.formatPhoneNumber(personalDetail.login);
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/isReportMessageAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import CONST from '../CONST';
* @returns {Boolean}
*/
export default function isReportMessageAttachment({text, html}) {
return text === CONST.ATTACHMENT_MESSAGE_TEXT && html !== CONST.ATTACHMENT_MESSAGE_TEXT;
const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i');
return text === CONST.ATTACHMENT_MESSAGE_TEXT && !!html.match(regex);
}
9 changes: 5 additions & 4 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,13 @@ class ReportActionCompose extends React.Component {
* @param {String} emoji
*/
addEmojiToTextBox(emoji) {
this.updateComment(ComposerUtils.insertText(this.comment, this.state.selection, emoji));
this.setState((prevState) => ({
selection: {
start: prevState.selection.start + emoji.length,
end: prevState.selection.start + emoji.length,
},
}));
this.updateComment(ComposerUtils.insertText(this.comment, this.state.selection, emoji));
}

/**
Expand Down Expand Up @@ -867,6 +867,7 @@ class ReportActionCompose extends React.Component {
const inputPlaceholder = this.getInputPlaceholder();
const shouldUseFocusedColor = !isBlockedFromConcierge && !this.props.disabled && (this.state.isFocused || this.state.isDraggingOver);
const hasExceededMaxCommentLength = this.state.hasExceededMaxCommentLength;
const isFullComposerAvailable = this.state.isFullComposerAvailable && !_.isEmpty(this.state.value);

return (
<View
Expand Down Expand Up @@ -908,7 +909,7 @@ class ReportActionCompose extends React.Component {
style={[
styles.dFlex,
styles.flexColumn,
this.state.isFullComposerAvailable || this.props.isComposerFullSize ? styles.justifyContentBetween : styles.justifyContentEnd,
isFullComposerAvailable || this.props.isComposerFullSize ? styles.justifyContentBetween : styles.justifyContentEnd,
]}
>
{this.props.isComposerFullSize && (
Expand All @@ -928,7 +929,7 @@ class ReportActionCompose extends React.Component {
</TouchableOpacity>
</Tooltip>
)}
{!this.props.isComposerFullSize && this.state.isFullComposerAvailable && (
{!this.props.isComposerFullSize && isFullComposerAvailable && (
<Tooltip text={this.props.translate('reportActionCompose.expand')}>
<TouchableOpacity
onPress={(e) => {
Expand Down Expand Up @@ -1039,7 +1040,7 @@ class ReportActionCompose extends React.Component {
isDisabled={isComposeDisabled || isBlockedFromConcierge || this.props.disabled}
selection={this.state.selection}
onSelectionChange={this.onSelectionChange}
isFullComposerAvailable={this.state.isFullComposerAvailable}
isFullComposerAvailable={isFullComposerAvailable}
setIsFullComposerAvailable={this.setIsFullComposerAvailable}
isComposerFullSize={this.props.isComposerFullSize}
value={this.state.value}
Expand Down
12 changes: 10 additions & 2 deletions tests/unit/CurrencyUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@ describe('CurrencyUtils', () => {
describe('convertToSmallestUnit', () => {
test.each([
[CONST.CURRENCY.USD, 25, 2500],
[CONST.CURRENCY.USD, 25.25, 2525],
[CONST.CURRENCY.USD, 25.5, 2550],
[CONST.CURRENCY.USD, 25.5, 2550],
[CONST.CURRENCY.USD, 2500, 250000],
[CONST.CURRENCY.USD, 80.6, 8060],
[CONST.CURRENCY.USD, 80.9, 8090],
[CONST.CURRENCY.USD, 80.99, 8099],
['JPY', 25, 25],
['JPY', 25.25, 25],
['JPY', 25.5, 26],
['JPY', 2500, 2500],
['JPY', 25.5, 25],
['JPY', 80.6, 81],
['JPY', 80.9, 81],
['JPY', 80.99, 81],
])('Correctly converts %s to amount in smallest units', (currency, amount, expectedResult) => {
expect(CurrencyUtils.convertToSmallestUnit(currency, amount)).toBe(expectedResult);
});
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/isReportMessageAttachmentTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import isReportMessageAttachment from '../../src/libs/isReportMessageAttachment';

describe('isReportMessageAttachment', () => {
it('returns true if a report action is attachment', () => {
const message = {
text: '[Attachment]',
html: '<img src="https://www.expensify.com/chat-attachments/1260926113061804740/w_66791ca35b3c34c2a0eda4d065d97c9907cadd61.jpg.1024.jpg" data-expensify-source="https://www.expensify.com/chat-attachments/1260926113061804740/w_66791ca35b3c34c2a0eda4d065d97c9907cadd61.jpg" data-name="rn_image_picker_lib_temp_636b71a8-18fd-41a1-9725-6587ffb207a7.jpg" data-expensify-width="4000" data-expensify-height="3000" />',
};
expect(isReportMessageAttachment(message)).toBe(true);
});

it('returns false if a report action is not attachment', () => {
let message = {text: '[Attachment]', html: '<em>[Attachment]</em>'};
expect(isReportMessageAttachment(message)).toBe(false);

message = {text: '[Attachment]', html: '<a href="https://www.google.com" target="_blank" rel="noreferrer noopener">[Attachment]</a>'};
expect(isReportMessageAttachment(message)).toBe(false);

message = {text: '[Attachment]', html: '<a href="https://www.google.com/?data-expensify-source=" target="_blank" rel="noreferrer noopener">[Attachment]</a>'};
expect(isReportMessageAttachment(message)).toBe(false);
});
});

0 comments on commit 02bce91

Please sign in to comment.