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

Mark posts as read on image view in normal mode #645

Merged
merged 6 commits into from
Jul 15, 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
12 changes: 11 additions & 1 deletion src/components/common/ImagePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ interface IProps {
postId: number;
isNsfw: boolean;
recycled?: React.MutableRefObject<{}>;
setPostRead?: () => void;
}

function ImagePreview({ images, postId, recycled, isNsfw }: IProps) {
function ImagePreview({
images,
postId,
recycled,
isNsfw,
setPostRead,
}: IProps) {
if (images.length === 1) {
return (
<ImageViewer
source={{ uri: images[0] }}
nsfw={isNsfw}
postId={postId}
recycled={recycled}
setPostRead={setPostRead}
/>
);
}
Expand All @@ -32,6 +40,7 @@ function ImagePreview({ images, postId, recycled, isNsfw }: IProps) {
recycled={recycled}
heightOverride={200}
widthOverride={Dimensions.get("screen").width / 2}
setPostRead={setPostRead}
/>
<ImageViewer
source={{ uri: images[1] }}
Expand All @@ -40,6 +49,7 @@ function ImagePreview({ images, postId, recycled, isNsfw }: IProps) {
recycled={recycled}
heightOverride={200}
widthOverride={Dimensions.get("screen").width / 2}
setPostRead={setPostRead}
/>
<Box position="absolute" right={1} bottom={1}>
<Box
Expand Down
8 changes: 7 additions & 1 deletion src/components/common/ImageViewer/ImageViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface IProps {
recycled?: React.MutableRefObject<{}>;
nsfw?: boolean;
buttonMode?: boolean;
setPostRead?: () => void;
}

interface MeasureResult {
Expand All @@ -71,6 +72,7 @@ function ImageViewer({
recycled,
nsfw,
buttonMode = false,
setPostRead,
}: IProps) {
const theme = useTheme();

Expand All @@ -82,7 +84,7 @@ function ImageViewer({
const [accessoriesVisible, setAccessoriesVisible] = useState(false);

// NSFW stuff, we need this hack for some reason
const { blurNsfw } = useAppSelector(selectSettings);
const { blurNsfw, markReadOnPostImageView } = useAppSelector(selectSettings);
const [blurIntensity, setBlurIntensity] = useState(99);

// Animation stuff
Expand Down Expand Up @@ -168,6 +170,10 @@ function ImageViewer({
if (!expanded) {
if (onPress) onPress();

if (setPostRead && markReadOnPostImageView) {
setPostRead();
}

// Make sure that the initial value for last zoom is reset
lastScale.value = 1;
zoomScale.value = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IProps {
}

// TODO Fix the set Post read here
function FeedContentPreview({ post, recycled }: IProps) {
function FeedContentPreview({ post, recycled, setPostRead }: IProps) {
const theme = useTheme();
const { fontWeightPostTitle } = useAppSelector(selectSettings);

Expand Down Expand Up @@ -66,6 +66,7 @@ function FeedContentPreview({ post, recycled }: IProps) {
postId={post.post.id}
isNsfw={post.post.nsfw || post.community.nsfw}
recycled={recycled}
setPostRead={setPostRead}
/>
</Box>
)}
Expand Down
Loading