Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can now download and run Memmy on your iOS device by using TestFlight. To jo

## About

An Apollo-inspired iOS client for using [Lemmy](https://github.com/LemmyNet/lemmy), a federated link aggregator. Heavly influenced and inspired by Apollo for Reddit. Thanks [Christian](https://github.com/christianselig).
An Apollo-inspired iOS client for using [Lemmy](https://github.com/LemmyNet/lemmy), a federated link aggregator. Heavily influenced and inspired by Apollo for Reddit. Thanks [Christian](https://github.com/christianselig).

## Work in Progress
This is a work in progress and is not in a functional state - yet. I intend to release builds at least nightly on TestFlight, although I am going a bit fast right now (getting ready for the withdraw from no longer having Apollo!)
Expand Down Expand Up @@ -37,7 +37,7 @@ npx pod install

yarn ios
```
A simulator should open with the app running. To change the device type or to deply to your physical device, run `yarn ios --device` and select the device you want to deploy to.
A simulator should open with the app running. To change the device type or to deploy to your physical device, run `yarn ios --device` and select the device you want to deploy to.

## Info
This application uses Expo. The various pluses to using Expo/React Native are the following:
Expand Down
5 changes: 5 additions & 0 deletions src/components/common/Comments/CommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface IProps {
comment: ILemmyComment;
depth?: number;
isUnreadReply?: boolean;
isMod: boolean;
onVote: (value: ILemmyVote) => void;
onPress: () => unknown;
}
Expand All @@ -31,6 +32,7 @@ function CommentItem({
comment,
depth,
isUnreadReply,
isMod,
onVote,
onPress,
}: IProps) {
Expand All @@ -45,6 +47,8 @@ function CommentItem({
comment,
});

console.log("isMod: ", isMod);

const voteOption = useMemo(
() =>
onVote ? (
Expand Down Expand Up @@ -78,6 +82,7 @@ function CommentItem({
<AvatarUsername
creator={comment.comment.creator}
opId={comment.comment.post.creator_id}
isMod={isMod}
/>
<SmallVoteIcons
upvotes={comment.comment.counts.upvotes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ function ModeratorList({ moderators }: IProps) {
return (
<VStack space={1}>
{moderators.map((moderator) => (
<AvatarUsername creator={moderator.moderator} isMod showPill={false} />
<AvatarUsername
creator={moderator.moderator}
key={moderator.moderator.id}
isMod
showPill={false}
/>
))}
</VStack>
);
Expand Down
20 changes: 17 additions & 3 deletions src/components/screens/Post/PostScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { clearEditComment } from "../../../slices/comments/editCommentSlice";
import { clearNewComment } from "../../../slices/comments/newCommentSlice";
import PostCommentItem from "./components/PostCommentItem";
import usePost from "../../../hooks/post/usePost";
import useCommunity from "../../../hooks/communities/useCommunity";
import CommentSortButton from "./components/CommentSortButton";

interface IProps {
Expand All @@ -38,6 +39,10 @@ function PostScreen({ navigation }: IProps) {
const { postKey } = useRoute<any>().params;
const postHook = usePost();
const currentPost = useCurrentPost(postKey);
const communityHook = useCommunity(currentPost.post.community_id);
const isMod = communityHook.moderators.some(
(mod) => mod.moderator.id === currentPost.post.creator_id
);
const newComment = useNewComment();
const editedComment = useEditedComment();
const rerenderComments = usePostRerenderComments(postKey);
Expand All @@ -48,6 +53,8 @@ function PostScreen({ navigation }: IProps) {
const { t } = useTranslation();
const theme = useTheme();

console.log("currentPost_community_id: ", currentPost.post.community_id);

useEffect(() => {
postHook.doLoad();

Expand All @@ -67,6 +74,10 @@ function PostScreen({ navigation }: IProps) {
});
}, [commentsSort]);

useEffect(() => {
communityHook.doLoad();
}, []);

useEffect(
() =>
// Remove the post when we are finished
Expand Down Expand Up @@ -134,15 +145,18 @@ function PostScreen({ navigation }: IProps) {
clearEditComment();
}, [editedComment]);

// Get the comments that are visible. Only recal whenever we trigger the render
// Get the comments that are visible. Only recall whenever we trigger the render
const visibleComments = useMemo(
() => comments.filter((c) => !c.hidden),
[rerenderComments]
);

console.log("PS_isMod: ", isMod);
// Comment item renderer
const commentItem = useCallback(
({ item }) => <PostCommentItem commentId={item.comment.comment.id} />,
({ item }) => (
<PostCommentItem commentId={item.comment.comment.id} isMod={isMod} />
),
[currentPost.post.id]
);

Expand Down Expand Up @@ -170,7 +184,7 @@ function PostScreen({ navigation }: IProps) {
return (
<VStack flex={1} backgroundColor={theme.colors.app.bg}>
<FlashList
ListHeaderComponent={<PostHeader />}
ListHeaderComponent={<PostHeader isMod />}
ListFooterComponent={<PostFooter />}
data={visibleComments}
renderItem={commentItem}
Expand Down
14 changes: 12 additions & 2 deletions src/components/screens/Post/components/PostCommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {

interface IProps {
commentId: number;
isMod: boolean;
}

function PostCommentItem({ commentId }: IProps) {
function PostCommentItem({ commentId, isMod }: IProps) {
const { postKey } = useRoute<any>().params;
const comment = usePostComment(postKey, commentId);

Expand Down Expand Up @@ -68,7 +69,16 @@ function PostCommentItem({ commentId }: IProps) {
});
}, [comment.comment.comment.id]);

return <CommentItem comment={comment} onVote={onVote} onPress={onPress} />;
console.log("PCI_isMod: ", isMod);

return (
<CommentItem
comment={comment}
onVote={onVote}
onPress={onPress}
isMod={isMod}
/>
);
}

export default React.memo(PostCommentItem);
4 changes: 2 additions & 2 deletions src/components/screens/Post/components/PostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from "../../../../stores/posts/postsStore";
import { setPostCollapsed } from "../../../../stores/posts/actions";

function PostHeader() {
function PostHeader({ isMod = false }: { isMod?: boolean }) {
const { postKey } = useRoute<any>().params;

const currentPost = useCurrentPost(postKey);
Expand Down Expand Up @@ -59,7 +59,7 @@ function PostHeader() {
</Pressable>

<HStack mb={2} mx={4} space={2}>
<AvatarUsername creator={currentPost.creator} />
<AvatarUsername creator={currentPost.creator} isMod={isMod} />
</HStack>
<HStack space={2} mx={4} mb={2}>
<CommunityLink
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/communities/useCommunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { handleLemmyError } from "../../helpers/LemmyErrorHelper";

interface UseCommunity {
community: CommunityView | null;
moderators: CommunityModeratorView[] | [];
moderators: CommunityModeratorView[];
setCommunity: React.Dispatch<React.SetStateAction<CommunityView | null>>;
communityLoading: boolean;
communityError: boolean;
Expand Down