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 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 };

View File

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

View File

@ -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}
/>
</Col>
<PostItem
@ -73,6 +75,7 @@ export class PostFeed extends React.Component {
isReply={true}
parentPost={parentNode.post}
isRelativeTime={true}
vip={vip}
/>
</React.Fragment>
);
@ -92,6 +95,7 @@ export class PostFeed extends React.Component {
parentPost={parentNode?.post}
isReply={!!parentNode}
isRelativeTime={true}
vip={vip}
/>
);
});

View File

@ -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) {

View File

@ -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} />
</Col>
) : null }

View File

@ -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}
/>
</Box>
<Box
@ -101,7 +104,9 @@ export default function PostReplies(props) {
parentNode={node}
pendingSize={pendingSize}
association={association}
group={group}
groups={groups}
vip={vip}
api={api}
history={history}
baseUrl={baseUrl}

View File

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