forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#25758 from margelo/refactor-report-actio…
…n-compose Performance: chat input
- Loading branch information
Showing
21 changed files
with
2,468 additions
and
1,423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import _ from 'underscore'; | ||
import * as Report from '../actions/Report'; | ||
|
||
/** | ||
* Save draft report comment. Debounced to happen at most once per second. | ||
* @param {String} reportID | ||
* @param {String} comment | ||
*/ | ||
const debouncedSaveReportComment = _.debounce((reportID, comment) => { | ||
Report.saveReportComment(reportID, comment || ''); | ||
}, 1000); | ||
|
||
export default debouncedSaveReportComment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
|
||
const draftCommentMap = {}; | ||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, | ||
callback: (value, key) => { | ||
if (!key) return; | ||
|
||
const reportID = key.replace(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, ''); | ||
draftCommentMap[reportID] = value; | ||
}, | ||
}); | ||
|
||
/** | ||
* Returns a draft comment from the onyx collection. | ||
* Note: You should use the HOCs/hooks to get onyx data, instead of using this directly. | ||
* A valid use case to use this is if the value is only needed once for an initial value. | ||
* @param {String} reportID | ||
* @returns {String|undefined} | ||
*/ | ||
export default function getDraftComment(reportID) { | ||
return draftCommentMap[reportID]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import CONST from '../CONST'; | ||
|
||
/** | ||
* Return the max available index for arrow manager. | ||
* @param {Number} numRows | ||
* @param {Boolean} isAutoSuggestionPickerLarge | ||
* @returns {Number} | ||
*/ | ||
function getMaxArrowIndex(numRows, isAutoSuggestionPickerLarge) { | ||
// rowCount is number of emoji/mention suggestions. For small screen we can fit 3 items | ||
// and for large we show up to 20 items for mentions/emojis | ||
const rowCount = isAutoSuggestionPickerLarge | ||
? Math.min(numRows, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS) | ||
: Math.min(numRows, CONST.AUTO_COMPLETE_SUGGESTER.MIN_AMOUNT_OF_SUGGESTIONS); | ||
|
||
// -1 because we start at 0 | ||
return rowCount - 1; | ||
} | ||
|
||
/** | ||
* Trims first character of the string if it is a space | ||
* @param {String} str | ||
* @returns {String} | ||
*/ | ||
function trimLeadingSpace(str) { | ||
return str.slice(0, 1) === ' ' ? str.slice(1) : str; | ||
} | ||
|
||
export {getMaxArrowIndex, trimLeadingSpace}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
|
||
let modalState = {}; | ||
|
||
Onyx.connect({ | ||
key: ONYXKEYS.MODAL, | ||
callback: (val) => { | ||
modalState = val; | ||
}, | ||
}); | ||
|
||
/** | ||
* Returns the modal state from onyx. | ||
* Note: You should use the HOCs/hooks to get onyx data, instead of using this directly. | ||
* A valid use case to use this is if the value is only needed once for an initial value. | ||
* @returns {Object} | ||
*/ | ||
export default function getModalState() { | ||
return modalState; | ||
} |
Oops, something went wrong.