diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -42,6 +42,7 @@ import Calendar from './calendar/calendar.react.js'; import Chat from './chat/chat.react.js'; import { EditModalProvider } from './chat/edit-message-provider.js'; +import { MemberListSidebarProvider } from './chat/member-list-sidebar/member-list-sidebar-provider.react.js'; import NavigationArrows from './components/navigation-arrows.react.js'; import { initOpaque } from './crypto/opaque-utils.js'; import { getDatabaseModule } from './database/database-module-provider.js'; @@ -215,13 +216,15 @@ - - - - - - - {content} + + + + + + + + {content} + diff --git a/web/chat/member-list-sidebar/member-list-sidebar-provider.react.js b/web/chat/member-list-sidebar/member-list-sidebar-provider.react.js new file mode 100644 --- /dev/null +++ b/web/chat/member-list-sidebar/member-list-sidebar-provider.react.js @@ -0,0 +1,48 @@ +// @flow + +import invariant from 'invariant'; +import * as React from 'react'; + +import type { SetState } from 'lib/types/hook-types.js'; + +export type MemberListSidebarContextType = { + +showMemberListSidebar: boolean, + +setShowMemberListSidebar: SetState, +}; + +const MemberListSidebarContext: React.Context = + React.createContext(); + +type Props = { + +children: React.Node, +}; + +function MemberListSidebarProvider(props: Props): React.Node { + const { children } = props; + + const [showMemberListSidebar, setShowMemberListSidebar] = + React.useState(false); + + const contextValue = React.useMemo( + () => ({ + showMemberListSidebar, + setShowMemberListSidebar, + }), + [showMemberListSidebar, setShowMemberListSidebar], + ); + + return ( + + {children} + + ); +} + +function useMemberListSidebarContext(): MemberListSidebarContextType { + const memberListSidebarContext = React.useContext(MemberListSidebarContext); + + invariant(memberListSidebarContext, 'memberListSidebarContext should be set'); + return memberListSidebarContext; +} + +export { MemberListSidebarProvider, useMemberListSidebarContext };