From 983df1c686ea64f5fbbd7c900863c888d108ca20 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 1 Apr 2021 16:11:27 -0500 Subject: [PATCH] interface: vip prop drilling for group feed --- .../views/landscape/components/Home/GroupFeed.js | 15 ++++++++++++--- .../views/landscape/components/Home/GroupHome.js | 2 ++ .../landscape/components/Home/Post/PostFeed.js | 6 +++++- .../landscape/components/Home/Post/PostInput.js | 2 +- .../components/Home/Post/PostItem/PostItem.js | 8 +++++++- .../landscape/components/Home/Post/PostReplies.js | 5 +++++ .../components/Home/Post/PostTimeline.js | 7 ++++++- 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/pkg/interface/src/views/landscape/components/Home/GroupFeed.js b/pkg/interface/src/views/landscape/components/Home/GroupFeed.js index 9abbe3249..65fab66ac 100644 --- a/pkg/interface/src/views/landscape/components/Home/GroupFeed.js +++ b/pkg/interface/src/views/landscape/components/Home/GroupFeed.js @@ -12,15 +12,22 @@ import PostTimeline from './Post/PostTimeline'; import PostReplies from './Post/PostReplies'; import useMetadataState from '~/logic/state/metadata'; +import useGroupState from '~/logic/state/group'; function GroupFeed(props) { const { baseUrl, api, - graphPath + graphPath, + groupPath, + vip } = props; + console.log(vip); + const groups = useGroupState(state => state.groups); + const group = groups[groupPath]; + const associations = useMetadataState(state => state.associations); const graphs = useGraphState(state => state.graphs); const graphResource = resourceFromPath(graphPath); @@ -68,7 +75,9 @@ function GroupFeed(props) { api={api} history={history} graphPath={graphPath} + group={group} association={association} + vip={vip} graph={graph} pendingSize={pendingSize} /> ); @@ -83,7 +92,9 @@ function GroupFeed(props) { api={api} history={history} graphPath={graphPath} + group={group} association={association} + vip={vip} graph={graph} pendingSize={pendingSize} /> ); @@ -93,6 +104,4 @@ function GroupFeed(props) { ); } -GroupFeed.whyDidYouRender = true; - export { GroupFeed }; diff --git a/pkg/interface/src/views/landscape/components/Home/GroupHome.js b/pkg/interface/src/views/landscape/components/Home/GroupHome.js index 41822e387..0e34875ab 100644 --- a/pkg/interface/src/views/landscape/components/Home/GroupHome.js +++ b/pkg/interface/src/views/landscape/components/Home/GroupHome.js @@ -59,6 +59,8 @@ function GroupHome(props) { diff --git a/pkg/interface/src/views/landscape/components/Home/Post/PostFeed.js b/pkg/interface/src/views/landscape/components/Home/Post/PostFeed.js index b063c3cac..632fb0b6c 100644 --- a/pkg/interface/src/views/landscape/components/Home/Post/PostFeed.js +++ b/pkg/interface/src/views/landscape/components/Home/Post/PostFeed.js @@ -23,7 +23,8 @@ export class PostFeed extends React.Component { history, baseUrl, parentNode, - association + association, + vip } = this.props; const graphResource = resourceFromPath(graphPath); const node = graph.get(index); @@ -59,6 +60,7 @@ export class PostFeed extends React.Component { history={history} isParent={true} isRelativeTime={false} + vip={vip} /> ); @@ -92,6 +95,7 @@ export class PostFeed extends React.Component { parentPost={parentNode?.post} isReply={!!parentNode} isRelativeTime={true} + vip={vip} /> ); }); diff --git a/pkg/interface/src/views/landscape/components/Home/Post/PostInput.js b/pkg/interface/src/views/landscape/components/Home/Post/PostInput.js index ab1275586..f73c5576a 100644 --- a/pkg/interface/src/views/landscape/components/Home/Post/PostInput.js +++ b/pkg/interface/src/views/landscape/components/Home/Post/PostInput.js @@ -7,7 +7,7 @@ import tokenizeMessage from '~/logic/lib/tokenizeMessage'; import { useToggleState } from '~/logic/lib/useToggleState'; import { createPost } from '~/logic/api/graph'; import useStorage from '~/logic/lib/useStorage'; -import { resourceFromPath } from '~/logic/lib/group'; +import { resourceFromPath, isWriter } from '~/logic/lib/group'; export function PostInput(props) { diff --git a/pkg/interface/src/views/landscape/components/Home/Post/PostItem/PostItem.js b/pkg/interface/src/views/landscape/components/Home/Post/PostItem/PostItem.js index 61df01070..16aa1e006 100644 --- a/pkg/interface/src/views/landscape/components/Home/Post/PostItem/PostItem.js +++ b/pkg/interface/src/views/landscape/components/Home/Post/PostItem/PostItem.js @@ -7,7 +7,7 @@ import { PostInput } from '../PostInput'; import { Mention } from "~/views/components/MentionText"; import withState from '~/logic/lib/withState'; import { useHovering } from '~/logic/lib/util'; -import { resourceFromPath } from '~/logic/lib/group'; +import { resourceFromPath, isWriter } from '~/logic/lib/group'; class PostItem extends React.Component { @@ -21,6 +21,11 @@ class PostItem extends React.Component { this.submitCallback = this.submitCallback.bind(this); } + canWrite() { + const { group, association } = this.props; + return isWriter(group, association.resource); + } + toggleReplyMode() { this.setState({ inReplyMode: !this.state.inReplyMode }); } @@ -120,6 +125,7 @@ class PostItem extends React.Component { api={api} graphPath={graphPath} index={indexString} + canWrite={canWrite} submitCallback={this.submitCallback} /> ) : null } diff --git a/pkg/interface/src/views/landscape/components/Home/Post/PostReplies.js b/pkg/interface/src/views/landscape/components/Home/Post/PostReplies.js index c329266f7..a110287fc 100644 --- a/pkg/interface/src/views/landscape/components/Home/Post/PostReplies.js +++ b/pkg/interface/src/views/landscape/components/Home/Post/PostReplies.js @@ -16,6 +16,8 @@ export default function PostReplies(props) { association, groups, graphPath, + group, + vip, pendingSize } = props; @@ -74,6 +76,7 @@ export default function PostReplies(props) { baseUrl={baseUrl} history={history} isParent={true} + vip={vip} /> + graphPath={graphPath} + vip={vip} />