mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 06:13:40 +00:00
Merge pull request #4098 from overleaf/msm-fix-application-provider-required-user
Fixed `isRequired` usages for `ApplicationProvider.value.user` GitOrigin-RevId: 0f3db77fa5da1cb0aec29ef112d1044173df88e0
This commit is contained in:
parent
614734c3e1
commit
f5942f1a7b
3 changed files with 15 additions and 3 deletions
|
@ -15,7 +15,9 @@ function ChatPane() {
|
|||
const { t } = useTranslation()
|
||||
|
||||
const { chatIsOpen } = useLayoutContext({ chatIsOpen: PropTypes.bool })
|
||||
const { user } = useApplicationContext()
|
||||
const { user } = useApplicationContext({
|
||||
user: PropTypes.shape({ id: PropTypes.string.isRequired }.isRequired),
|
||||
})
|
||||
|
||||
const {
|
||||
status,
|
||||
|
|
|
@ -16,9 +16,13 @@ ApplicationContext.Provider.propTypes = {
|
|||
|
||||
export function ApplicationProvider({ children }) {
|
||||
const applicationContextValue = {
|
||||
user: window.user,
|
||||
gitBridgePublicBaseUrl: window.gitBridgePublicBaseUrl,
|
||||
}
|
||||
|
||||
if (window.user.id) {
|
||||
applicationContextValue.user = window.user
|
||||
}
|
||||
|
||||
return (
|
||||
<ApplicationContext.Provider value={applicationContextValue}>
|
||||
{children}
|
||||
|
|
|
@ -8,12 +8,18 @@ import { LayoutProvider } from './layout-context'
|
|||
import { CompileProvider } from './compile-context'
|
||||
|
||||
export function ContextRoot({ children, ide, settings }) {
|
||||
const isAnonymousUser = window.user.id == null
|
||||
|
||||
return (
|
||||
<ApplicationProvider>
|
||||
<EditorProvider ide={ide} settings={settings}>
|
||||
<CompileProvider $scope={ide.$scope}>
|
||||
<LayoutProvider $scope={ide.$scope}>
|
||||
<ChatProvider>{children}</ChatProvider>
|
||||
{isAnonymousUser ? (
|
||||
children
|
||||
) : (
|
||||
<ChatProvider>{children}</ChatProvider>
|
||||
)}
|
||||
</LayoutProvider>
|
||||
</CompileProvider>
|
||||
</EditorProvider>
|
||||
|
|
Loading…
Add table
Reference in a new issue