Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup #783

Merged
merged 2 commits into from
Jul 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion ios/Memmy/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<key>CFBundleVersion</key>
<string>2</string>
<key>CodePushDeploymentKey</key>
<string>l3pg50FJ4Bgt5LrFzkh0d10d8ukjpoAptMP2g</string>
<string>f3fsdf</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
11 changes: 11 additions & 0 deletions src/components/common/ImageViewer/ImageViewFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,29 @@ import { saveImage } from "../../../helpers/ImageHelper";
import { shareLink } from "../../../helpers/ShareHelper";
import IconButtonWithText from "../IconButtonWithText";
import SFIcon from "../icons/SFIcon";
import { useAppDispatch } from "../../../../store";
import { showToast } from "../../../slices/toast/toastSlice";

interface ImageViewFooterProps {
source: string;
}

function ImageViewFooter({ source }: ImageViewFooterProps) {
const theme = useTheme();
const dispatch = useAppDispatch();

const onSave = async () => {
onGenericHapticFeedback();

await saveImage(source);

dispatch(
showToast({
message: "Image saved.",
duration: 1500,
variant: "success",
})
);
};

const onShare = async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/common/ImageViewer/ImageViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { useAppSelector } from "../../../../store";
import { selectSettings } from "../../../slices/settings/settingsSlice";
import ImageButton from "../Buttons/ImageButton";
import { onGenericHapticFeedback } from "../../../helpers/HapticFeedbackHelpers";
import Toast from "../Toast";

interface IProps {
source: string;
Expand Down Expand Up @@ -618,6 +619,7 @@ function ImageViewer({
</Pressable>
)}
<Modal visible={expanded} transparent>
<Toast />
{/* eslint-disable-next-line react/style-prop-object */}
<StatusBar style="dark" />
<Animated.View style={[accessoriesStyle]}>
Expand Down
20 changes: 13 additions & 7 deletions src/components/screens/Feed/components/FeedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ import {
} from "../../../../stores/feeds/feedsStore";
import { useCommunity } from "../../../../stores/communities/communitiesStore";
import loadFeedPosts from "../../../../stores/feeds/actions/loadFeedPosts";
import HideReadFAB from "../../../common/Buttons/HideReadFAB";
import setFeedPosts from "../../../../stores/feeds/actions/setFeedPosts";
import { removeReadPosts } from "../../../../helpers/LemmyHelpers";

interface FeedViewProps {
header?: () => React.ReactNode;
}

function FeedView({ header }: FeedViewProps) {
const { hideReadPostsOnFeed, showHideReadButton } =
useAppSelector(selectSettings);

const { key } = useRoute();

// Global state props
Expand Down Expand Up @@ -161,13 +167,13 @@ function FeedView({ header }: FeedViewProps) {
getItemType={getItemType}
/>
)}
{/* {hideReadPostsOnFeed && showHideReadButton && showFab && ( */}
{/* <HideReadFAB */}
{/* onPress={() => { */}
{/* feed.setPosts(removeReadPosts(feed.posts)); */}
{/* }} */}
{/* /> */}
{/* )} */}
{hideReadPostsOnFeed && showHideReadButton && (
<HideReadFAB
onPress={() => {
setFeedPosts(key, removeReadPosts(posts));
}}
/>
)}
</View>
);
}
Expand Down
26 changes: 26 additions & 0 deletions src/components/screens/Post/components/PostCommentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ function PostCommentItem({ commentId }: IProps) {
);
prevComment.collapsed = !prevComment.collapsed;
prev.rerenderComments = !prev.rerenderComments;

const prevToHide = prev.commentsState.comments.filter(
(c) =>
c.comment.comment.path.includes(prevComment.comment.comment.path) &&
c.comment.comment.id !== commentId
);

if (!prevComment.collapsed) {
prevToHide.forEach((c) => {
const shouldUnhide =
prevToHide.findIndex(
(cc) =>
cc.collapsed &&
c.comment.comment.path.includes(cc.comment.comment.path) &&
c.comment.comment.id !== cc.comment.comment.id
) === -1;

if (shouldUnhide) {
c.hidden = false;
}
});
} else {
prevToHide.forEach((c) => {
c.hidden = true;
});
}
});
}, [comment.comment.comment.id]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ function ViewAccountsScreen({ navigation }: ViewAccountsScreenProps) {
<ScrollView backgroundColor={theme.colors.app.bg}>
<LoadingModalTransparent loading={notifications.loading} />
<CTable>
<CSection header={t("settings.accounts.current")}>
<CSection
header={t("settings.accounts.current")}
footer="To switch accounts, simply press and hold the Profile button in the tab bar."
>
<CCell
cellStyle="RightDetail"
title={t("Server")}
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/comments/useNewComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const useNewComment = () => {
parent_id: responseTo.comment
? responseTo.comment.comment.id
: undefined,
language_id: responseTo.languageId,
language_id:
responseTo.languageId === 0 ? undefined : responseTo.languageId,
});

useUpdatesStore
Expand Down
10 changes: 9 additions & 1 deletion src/hooks/post/usePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from "../../stores/posts/postsStore";
import { setPostCollapsed } from "../../stores/posts/actions";
import loadPostComments from "../../stores/posts/actions/loadPostComments";
import loadCommunity from "../../stores/communities/actions/loadCommunity";
import { getBaseUrl } from "../../helpers/LinkHelper";

export interface UsePost {
doLoad: () => void;
Expand All @@ -22,8 +24,14 @@ const usePost = (): UsePost => {

const doLoad = useCallback(() => {
loadPostComments(postKey, {
sortType: commentsSortType, // TODO Use default here
sortType: commentsSortType,
}).then();
loadCommunity(
`${currentPost.community.name}@${getBaseUrl(
currentPost.community.actor_id
)}`,
true
).then();
}, [currentPost.post.id, commentsSortType]);

const onPostPress = useCallback(() => {
Expand Down
15 changes: 14 additions & 1 deletion src/stores/communities/actions/loadCommunity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import { useCommunitiesStore } from "../communitiesStore";
import { lemmyAuthToken, lemmyInstance } from "../../../LemmyInstance";
import { handleLemmyError } from "../../../helpers/LemmyErrorHelper";

const loadCommunity = async (communityName: string) => {
const loadCommunity = async (communityName: string, noRefresh = false) => {
const current = useCommunitiesStore
.getState()
.communityStates.get(communityName);

if (
noRefresh &&
current &&
!current.status.loading &&
!current.status.error
) {
return;
}

useCommunitiesStore.setState((state) => {
if (!state.communityStates.has(communityName)) {
state.communityStates.set(communityName, {
Expand Down
18 changes: 18 additions & 0 deletions src/stores/posts/postsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,21 @@ export const usePostComment = (postKey: string, commentId: number) =>
.get(postKey)
.commentsState.comments.find((c) => c.comment.comment.id === commentId)
);

export const usePostCommentCollapsed = (postKey: string, commentId: number) =>
usePostsStore(
(state) =>
state.posts
.get(postKey)
.commentsState.comments.find((c) => c.comment.comment.id === commentId)
.collapsed
);

export const usePostCommentHidden = (postKey: string, commentId: number) =>
usePostsStore(
(state) =>
state.posts
.get(postKey)
.commentsState.comments.find((c) => c.comment.comment.id === commentId)
.hidden
);
Loading