interface: vip prop drilling for group feed

This commit is contained in:
Logan Allen 2021-04-01 16:11:27 -05:00
parent e3bfca7783
commit 983df1c686
7 changed files with 38 additions and 7 deletions

View File

@ -12,15 +12,22 @@ import PostTimeline from './Post/PostTimeline';
import PostReplies from './Post/PostReplies'; import PostReplies from './Post/PostReplies';
import useMetadataState from '~/logic/state/metadata'; import useMetadataState from '~/logic/state/metadata';
import useGroupState from '~/logic/state/group';
function GroupFeed(props) { function GroupFeed(props) {
const { const {
baseUrl, baseUrl,
api, api,
graphPath graphPath,
groupPath,
vip
} = props; } = props;
console.log(vip);
const groups = useGroupState(state => state.groups);
const group = groups[groupPath];
const associations = useMetadataState(state => state.associations); const associations = useMetadataState(state => state.associations);
const graphs = useGraphState(state => state.graphs); const graphs = useGraphState(state => state.graphs);
const graphResource = resourceFromPath(graphPath); const graphResource = resourceFromPath(graphPath);
@ -68,7 +75,9 @@ function GroupFeed(props) {
api={api} api={api}
history={history} history={history}
graphPath={graphPath} graphPath={graphPath}
group={group}
association={association} association={association}
vip={vip}
graph={graph} graph={graph}
pendingSize={pendingSize} /> pendingSize={pendingSize} />
); );
@ -83,7 +92,9 @@ function GroupFeed(props) {
api={api} api={api}
history={history} history={history}
graphPath={graphPath} graphPath={graphPath}
group={group}
association={association} association={association}
vip={vip}
graph={graph} graph={graph}
pendingSize={pendingSize} /> pendingSize={pendingSize} />
); );
@ -93,6 +104,4 @@ function GroupFeed(props) {
); );
} }
GroupFeed.whyDidYouRender = true;
export { GroupFeed }; export { GroupFeed };

View File

@ -59,6 +59,8 @@ function GroupHome(props) {
<Route path={`${baseUrl}/feed`}> <Route path={`${baseUrl}/feed`}>
<GroupFeed <GroupFeed
graphPath={graphPath} graphPath={graphPath}
groupPath={groupPath}
vip={metadata.vip}
api={api} api={api}
baseUrl={baseUrl} /> baseUrl={baseUrl} />
</Route> </Route>

View File

@ -23,7 +23,8 @@ export class PostFeed extends React.Component {
history, history,
baseUrl, baseUrl,
parentNode, parentNode,
association association,
vip
} = this.props; } = this.props;
const graphResource = resourceFromPath(graphPath); const graphResource = resourceFromPath(graphPath);
const node = graph.get(index); const node = graph.get(index);
@ -59,6 +60,7 @@ export class PostFeed extends React.Component {
history={history} history={history}
isParent={true} isParent={true}
isRelativeTime={false} isRelativeTime={false}
vip={vip}
/> />
</Col> </Col>
<PostItem <PostItem
@ -73,6 +75,7 @@ export class PostFeed extends React.Component {
isReply={true} isReply={true}
parentPost={parentNode.post} parentPost={parentNode.post}
isRelativeTime={true} isRelativeTime={true}
vip={vip}
/> />
</React.Fragment> </React.Fragment>
); );
@ -92,6 +95,7 @@ export class PostFeed extends React.Component {
parentPost={parentNode?.post} parentPost={parentNode?.post}
isReply={!!parentNode} isReply={!!parentNode}
isRelativeTime={true} isRelativeTime={true}
vip={vip}
/> />
); );
}); });

View File

@ -7,7 +7,7 @@ import tokenizeMessage from '~/logic/lib/tokenizeMessage';
import { useToggleState } from '~/logic/lib/useToggleState'; import { useToggleState } from '~/logic/lib/useToggleState';
import { createPost } from '~/logic/api/graph'; import { createPost } from '~/logic/api/graph';
import useStorage from '~/logic/lib/useStorage'; import useStorage from '~/logic/lib/useStorage';
import { resourceFromPath } from '~/logic/lib/group'; import { resourceFromPath, isWriter } from '~/logic/lib/group';
export function PostInput(props) { export function PostInput(props) {

View File

@ -7,7 +7,7 @@ import { PostInput } from '../PostInput';
import { Mention } from "~/views/components/MentionText"; import { Mention } from "~/views/components/MentionText";
import withState from '~/logic/lib/withState'; import withState from '~/logic/lib/withState';
import { useHovering } from '~/logic/lib/util'; import { useHovering } from '~/logic/lib/util';
import { resourceFromPath } from '~/logic/lib/group'; import { resourceFromPath, isWriter } from '~/logic/lib/group';
class PostItem extends React.Component { class PostItem extends React.Component {
@ -21,6 +21,11 @@ class PostItem extends React.Component {
this.submitCallback = this.submitCallback.bind(this); this.submitCallback = this.submitCallback.bind(this);
} }
canWrite() {
const { group, association } = this.props;
return isWriter(group, association.resource);
}
toggleReplyMode() { toggleReplyMode() {
this.setState({ inReplyMode: !this.state.inReplyMode }); this.setState({ inReplyMode: !this.state.inReplyMode });
} }
@ -120,6 +125,7 @@ class PostItem extends React.Component {
api={api} api={api}
graphPath={graphPath} graphPath={graphPath}
index={indexString} index={indexString}
canWrite={canWrite}
submitCallback={this.submitCallback} /> submitCallback={this.submitCallback} />
</Col> </Col>
) : null } ) : null }

View File

@ -16,6 +16,8 @@ export default function PostReplies(props) {
association, association,
groups, groups,
graphPath, graphPath,
group,
vip,
pendingSize pendingSize
} = props; } = props;
@ -74,6 +76,7 @@ export default function PostReplies(props) {
baseUrl={baseUrl} baseUrl={baseUrl}
history={history} history={history}
isParent={true} isParent={true}
vip={vip}
/> />
</Box> </Box>
<Box <Box
@ -101,7 +104,9 @@ export default function PostReplies(props) {
parentNode={node} parentNode={node}
pendingSize={pendingSize} pendingSize={pendingSize}
association={association} association={association}
group={group}
groups={groups} groups={groups}
vip={vip}
api={api} api={api}
history={history} history={history}
baseUrl={baseUrl} baseUrl={baseUrl}

View File

@ -13,8 +13,10 @@ export default function PostTimeline(props) {
history, history,
association, association,
graphPath, graphPath,
group,
graph, graph,
pendingSize, pendingSize,
vip
} = props; } = props;
const graphResource = resourceFromPath(graphPath); const graphResource = resourceFromPath(graphPath);
const shouldRenderFeed = !!graph; const shouldRenderFeed = !!graph;
@ -45,7 +47,8 @@ export default function PostTimeline(props) {
alignItems="center"> alignItems="center">
<PostInput <PostInput
api={api} api={api}
graphPath={graphPath} /> graphPath={graphPath}
vip={vip} />
</Col> </Col>
<Box <Box
pl="2" pl="2"
@ -83,6 +86,8 @@ export default function PostTimeline(props) {
graph={graph} graph={graph}
pendingSize={pendingSize} pendingSize={pendingSize}
association={association} association={association}
group={group}
vip={vip}
api={api} api={api}
history={history} history={history}
baseUrl={baseUrl} baseUrl={baseUrl}