forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/20759-remove-new-notifiers-when-deleting…
…-last-message
- Loading branch information
Showing
25 changed files
with
178 additions
and
160 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,76 @@ | ||
import React, {createContext, forwardRef, useCallback, useState, useMemo} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
import Navigation from '../libs/Navigation/Navigation'; | ||
|
||
const CurrentReportIDContext = createContext(null); | ||
|
||
const withCurrentReportIDPropTypes = { | ||
/** Function to update the state */ | ||
updateCurrentReportID: PropTypes.func.isRequired, | ||
|
||
/** The top most report id */ | ||
currentReportID: PropTypes.string, | ||
}; | ||
|
||
const withCurrentReportIDDefaultProps = { | ||
currentReportID: '', | ||
}; | ||
|
||
function CurrentReportIDContextProvider(props) { | ||
const [currentReportID, setCurrentReportID] = useState(''); | ||
|
||
/** | ||
* This function is used to update the currentReportID | ||
* @param {Object} state root navigation state | ||
*/ | ||
const updateCurrentReportID = useCallback( | ||
(state) => { | ||
setCurrentReportID(Navigation.getTopmostReportId(state)); | ||
}, | ||
[setCurrentReportID], | ||
); | ||
|
||
/** | ||
* The context this component exposes to child components | ||
* @returns {Object} currentReportID to share between central pane and LHN | ||
*/ | ||
const contextValue = useMemo( | ||
() => ({ | ||
updateCurrentReportID, | ||
currentReportID, | ||
}), | ||
[updateCurrentReportID, currentReportID], | ||
); | ||
|
||
return <CurrentReportIDContext.Provider value={contextValue}>{props.children}</CurrentReportIDContext.Provider>; | ||
} | ||
|
||
CurrentReportIDContextProvider.displayName = 'CurrentReportIDContextProvider'; | ||
CurrentReportIDContextProvider.propTypes = { | ||
/** Actual content wrapped by this component */ | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
export default function withCurrentReportID(WrappedComponent) { | ||
const WithCurrentReportID = forwardRef((props, ref) => ( | ||
<CurrentReportIDContext.Consumer> | ||
{(currentReportIDUtils) => ( | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...currentReportIDUtils} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
/> | ||
)} | ||
</CurrentReportIDContext.Consumer> | ||
)); | ||
|
||
WithCurrentReportID.displayName = `withCurrentReportID(${getComponentDisplayName(WrappedComponent)})`; | ||
|
||
return WithCurrentReportID; | ||
} | ||
|
||
export {withCurrentReportIDPropTypes, withCurrentReportIDDefaultProps, CurrentReportIDContextProvider}; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.