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

fix: pressing the link thumbnail opens the browser #796

Merged
merged 1 commit into from
Jul 22, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import FastImage from "@gkasdorf/react-native-fast-image";
import { PostView } from "lemmy-js-client";
import { Box, useTheme, View } from "native-base";
import { Box, Pressable, useTheme, View } from "native-base";
import React from "react";
import { StyleSheet } from "react-native";
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { useAppSelector } from "../../../../../../store";
import { ExtensionType, LinkInfo } from "../../../../../helpers/LinkHelper";
import {
ExtensionType,
LinkInfo,
openLink,
} from "../../../../../helpers/LinkHelper";
import { selectSettings } from "../../../../../slices/settings/settingsSlice";

import { lemmyAuthToken, lemmyInstance } from "../../../../../LemmyInstance";
Expand All @@ -21,6 +27,7 @@ function CompactFeedItemThumbnail({
setPostRead: () => void;
}) {
const theme = useTheme();
const navigation = useNavigation<NativeStackNavigationProp<any>>();

const { markReadOnPostImageView } = useAppSelector(selectSettings);

Expand All @@ -37,6 +44,12 @@ function CompactFeedItemThumbnail({
}
};

const onLinkPress = () => {
if (!post.post.url) return;

openLink(post.post.url, navigation, theme.colors.app.bg);
};

return (
<Box
width={75}
Expand Down Expand Up @@ -69,7 +82,7 @@ function CompactFeedItemThumbnail({
size={20}
/>
)) || (
<>
<Pressable onPress={onLinkPress}>
{(post.post.thumbnail_url && (
<>
<FastImage
Expand Down Expand Up @@ -102,7 +115,7 @@ function CompactFeedItemThumbnail({
size={20}
/>
)}
</>
</Pressable>
)}
</Box>
);
Expand Down
Loading