Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
68c00b9
merge main
salonikumawat28 Oct 13, 2023
f0e9684
Merge branch 'main' of https://github.com/Expensify/App
salonikumawat28 Oct 13, 2023
0046065
Fix for private notes deep link showing not found view
salonikumawat28 Oct 14, 2023
f5921f1
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 18, 2023
ded201b
Moving default props outside HOC
salonikumawat28 Oct 18, 2023
10ef16f
Removing underscore omit func use
salonikumawat28 Oct 19, 2023
4c9185b
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 19, 2023
f4b515b
Fixing bug showing not found in empty notes case
salonikumawat28 Oct 19, 2023
f3608fc
Correcting forward ref
salonikumawat28 Oct 20, 2023
61edc03
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 25, 2023
713bdbb
Fixing private notes HOC based on review suggestions
salonikumawat28 Oct 25, 2023
f03f3e1
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 25, 2023
c4d713f
Removing isLoadingPrivateNote dep on userEffect
salonikumawat28 Oct 25, 2023
1668e8f
Fix default value of isLoadingPrivateNote
salonikumawat28 Oct 25, 2023
189e4b3
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 26, 2023
6fd24b1
Resolving merge issue
salonikumawat28 Oct 26, 2023
5da70bb
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Oct 26, 2023
ef41837
Fixing unnecessary server fetch for private notes
salonikumawat28 Oct 26, 2023
07508c7
renaming private notes undefined variable
salonikumawat28 Oct 26, 2023
4b96037
Merge branch 'main' of https://github.com/Expensify/App into issue_27704
salonikumawat28 Nov 6, 2023
b131ffb
Fixing new lint errors
salonikumawat28 Nov 6, 2023
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/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ export default {
title: 'Private notes',
personalNoteMessage: 'Keep notes about this chat here. You are the only person who can add, edit or view these notes.',
sharedNoteMessage: 'Keep notes about this chat here. Expensify employees and other users on the team.expensify.com domain can view these notes.',
notesUnavailable: 'No notes found for the user',
composerLabel: 'Notes',
myNote: 'My note',
},
Expand Down
1 change: 0 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ export default {
title: 'Notas privadas',
personalNoteMessage: 'Guarda notas sobre este chat aquí. Usted es la única persona que puede añadir, editar o ver estas notas.',
sharedNoteMessage: 'Guarda notas sobre este chat aquí. Los empleados de Expensify y otros usuarios del dominio team.expensify.com pueden ver estas notas.',
notesUnavailable: 'No se han encontrado notas para el usuario',
composerLabel: 'Notas',
myNote: 'Mi nota',
},
Expand Down
140 changes: 56 additions & 84 deletions src/pages/PrivateNotes/PrivateNotesEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, {useCallback, useMemo, useRef, useState} from 'react';
import {Keyboard} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand All @@ -19,8 +18,8 @@ import withLocalize from '@components/withLocalize';
import useLocalize from '@hooks/useLocalize';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import updateMultilineInputRange from '@libs/UpdateMultilineInputRange';
import withReportAndPrivateNotesOrNotFound from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import personalDetailsPropType from '@pages/personalDetailsPropType';
import reportPropTypes from '@pages/reportPropTypes';
import styles from '@styles/styles';
Expand All @@ -43,23 +42,14 @@ const propTypes = {
accountID: PropTypes.string,
}),
}).isRequired,

/** Session of currently logged in user */
session: PropTypes.shape({
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),
};

const defaultProps = {
report: {},
session: {
accountID: null,
},
personalDetailsList: {},
};

function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
function PrivateNotesEditPage({route, personalDetailsList, report}) {
const {translate} = useLocalize();

// We need to edit the note in markdown format, but display it in HTML format
Expand All @@ -81,8 +71,6 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
[report.reportID],
);

const isCurrentUserNote = Number(session.accountID) === Number(route.params.accountID);

// To focus on the input field when the page loads
const privateNotesInput = useRef(null);
const focusTimeoutRef = useRef(null);
Expand Down Expand Up @@ -119,73 +107,62 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
includeSafeAreaPaddingBottom={false}
testID={PrivateNotesEditPage.displayName}
>
<FullPageNotFoundView
shouldShow={
_.isEmpty(report) ||
_.isEmpty(report.privateNotes) ||
!_.has(report, ['privateNotes', route.params.accountID, 'note']) ||
!isCurrentUserNote ||
ReportUtils.isArchivedRoom(report)
}
subtitleKey="privateNotes.notesUnavailable"
<HeaderWithBackButton
title={translate('privateNotes.title')}
subtitle={translate('privateNotes.myNote')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.reportID, route.params.accountID))}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.PRIVATE_NOTES_FORM}
onSubmit={savePrivateNote}
style={[styles.flexGrow1, styles.ph5]}
submitButtonText={translate('common.save')}
enabledWhenOffline
>
<HeaderWithBackButton
title={translate('privateNotes.title')}
subtitle={translate('privateNotes.myNote')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.reportID, route.params.accountID))}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.PRIVATE_NOTES_FORM}
onSubmit={savePrivateNote}
style={[styles.flexGrow1, styles.ph5]}
submitButtonText={translate('common.save')}
enabledWhenOffline
<Text style={[styles.mb5]}>
{translate(
Str.extractEmailDomain(lodashGet(personalDetailsList, [route.params.accountID, 'login'], '')) === CONST.EMAIL.GUIDES_DOMAIN
? 'privateNotes.sharedNoteMessage'
: 'privateNotes.personalNoteMessage',
)}
</Text>
<OfflineWithFeedback
errors={{
...lodashGet(report, ['privateNotes', route.params.accountID, 'errors'], ''),
}}
onClose={() => Report.clearPrivateNotesError(report.reportID, route.params.accountID)}
style={[styles.mb3]}
>
<Text style={[styles.mb5]}>
{translate(
Str.extractEmailDomain(lodashGet(personalDetailsList, [route.params.accountID, 'login'], '')) === CONST.EMAIL.GUIDES_DOMAIN
? 'privateNotes.sharedNoteMessage'
: 'privateNotes.personalNoteMessage',
)}
</Text>
<OfflineWithFeedback
errors={{
...lodashGet(report, ['privateNotes', route.params.accountID, 'errors'], ''),
<InputWrapper
InputComponent={TextInput}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="privateNotes"
label={translate('privateNotes.composerLabel')}
accessibilityLabel={translate('privateNotes.title')}
autoCompleteType="off"
maxLength={CONST.MAX_COMMENT_LENGTH}
autoCorrect={false}
autoGrowHeight
textAlignVertical="top"
containerStyles={[styles.autoGrowHeightMultilineInput]}
defaultValue={privateNote}
value={privateNote}
onChangeText={(text) => {
debouncedSavePrivateNote(text);
setPrivateNote(text);
}}
onClose={() => Report.clearPrivateNotesError(report.reportID, route.params.accountID)}
style={[styles.mb3]}
>
<InputWrapper
InputComponent={TextInput}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="privateNotes"
label={translate('privateNotes.composerLabel')}
accessibilityLabel={translate('privateNotes.title')}
autoCompleteType="off"
maxLength={CONST.MAX_COMMENT_LENGTH}
autoCorrect={false}
autoGrowHeight
textAlignVertical="top"
containerStyles={[styles.autoGrowHeightMultilineInput]}
defaultValue={privateNote}
value={privateNote}
onChangeText={(text) => {
debouncedSavePrivateNote(text);
setPrivateNote(text);
}}
ref={(el) => {
if (!el) {
return;
}
privateNotesInput.current = el;
updateMultilineInputRange(privateNotesInput.current);
}}
/>
</OfflineWithFeedback>
</FormProvider>
</FullPageNotFoundView>
ref={(el) => {
if (!el) {
return;
}
privateNotesInput.current = el;
updateMultilineInputRange(privateNotesInput.current);
}}
/>
</OfflineWithFeedback>
</FormProvider>
</ScreenWrapper>
);
}
Expand All @@ -196,13 +173,8 @@ PrivateNotesEditPage.defaultProps = defaultProps;

export default compose(
withLocalize,
withReportAndPrivateNotesOrNotFound,
withOnyx({
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID.toString()}`,
},
session: {
key: ONYXKEYS.SESSION,
},
personalDetailsList: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
Expand Down
53 changes: 10 additions & 43 deletions src/pages/PrivateNotes/PrivateNotesListPage.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useEffect, useMemo} from 'react';
import React, {useMemo} from 'react';
import {ScrollView} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItem from '@components/MenuItem';
import networkPropTypes from '@components/networkPropTypes';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {withNetwork} from '@components/OnyxProvider';
import ScreenWrapper from '@components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useLocalize from '@hooks/useLocalize';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import * as UserUtils from '@libs/UserUtils';
import withReportAndPrivateNotesOrNotFound from '@pages/home/report/withReportAndPrivateNotesOrNotFound';
import personalDetailsPropType from '@pages/personalDetailsPropType';
import reportPropTypes from '@pages/reportPropTypes';
import styles from '@styles/styles';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand All @@ -47,8 +43,6 @@ const propTypes = {
/** All of the personal details for everyone */
personalDetailsList: PropTypes.objectOf(personalDetailsPropType),

/** Information about the network */
network: networkPropTypes.isRequired,
...withLocalizePropTypes,
};

Expand All @@ -60,17 +54,9 @@ const defaultProps = {
personalDetailsList: {},
};

function PrivateNotesListPage({report, personalDetailsList, network, session}) {
function PrivateNotesListPage({report, personalDetailsList, session}) {
const {translate} = useLocalize();

useEffect(() => {
if (network.isOffline && report.isLoadingPrivateNotes) {
return;
}
Report.getReportPrivateNote(report.reportID);
// eslint-disable-next-line react-hooks/exhaustive-deps -- do not add isLoadingPrivateNotes to dependencies
}, [report.reportID, network.isOffline]);

/**
* Gets the menu item for each workspace
*
Expand Down Expand Up @@ -124,26 +110,12 @@ function PrivateNotesListPage({report, personalDetailsList, network, session}) {
includeSafeAreaPaddingBottom={false}
testID={PrivateNotesListPage.displayName}
>
<FullPageNotFoundView
shouldShow={
_.isEmpty(report.reportID) ||
(!report.isLoadingPrivateNotes && network.isOffline && _.isEmpty(lodashGet(report, 'privateNotes', {}))) ||
ReportUtils.isArchivedRoom(report)
}
>
<HeaderWithBackButton
title={translate('privateNotes.title')}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<ScrollView contentContainerStyle={styles.flexGrow1}>
{report.isLoadingPrivateNotes && _.isEmpty(lodashGet(report, 'privateNotes', {})) ? (
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
) : (
_.map(privateNotes, (item, index) => getMenuItem(item, index))
)}
</ScrollView>
</FullPageNotFoundView>
<HeaderWithBackButton
title={translate('privateNotes.title')}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
<ScrollView contentContainerStyle={styles.flexGrow1}>{_.map(privateNotes, (item, index) => getMenuItem(item, index))}</ScrollView>
</ScreenWrapper>
);
}
Expand All @@ -154,13 +126,8 @@ PrivateNotesListPage.displayName = 'PrivateNotesListPage';

export default compose(
withLocalize,
withReportAndPrivateNotesOrNotFound,
withOnyx({
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID.toString()}`,
},
session: {
key: ONYXKEYS.SESSION,
},
personalDetailsList: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
Expand Down
Loading