Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Fixed different images downloading in entry list item #1472

Merged
merged 1 commit into from
Oct 3, 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
9 changes: 8 additions & 1 deletion src/common/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export function usePointsQuery(username: string, filter = 0) {
);
}

export function useImageDownloader(entry: Entry, noImage: string, width: number, height: number) {
export function useImageDownloader(
entry: Entry,
noImage: string,
width: number,
height: number,
enabled: boolean
) {
const { global } = useMappedStore();

const blobToBase64 = (blob: Blob) => {
Expand Down Expand Up @@ -77,6 +83,7 @@ export function useImageDownloader(entry: Entry, noImage: string, width: number,
}
},
{
enabled,
retryDelay: 3000
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@ interface Props {
export function EntryListItemThumbnail({ entry, noImage, isCrossPost, entryProp, history }: Props) {
const { global } = useMappedStore();

const { data: imgGrid } = useImageDownloader(entry, noImage, 600, 500);
const { data: imgRow } = useImageDownloader(entry, noImage, 260, 200);
const { data: imgGrid } = useImageDownloader(
entry,
noImage,
600,
500,
global.listStyle === "grid"
);
const { data: imgRow } = useImageDownloader(
entry,
noImage,
260,
200,
global.listStyle !== "grid"
);

return (
<div className={"item-image " + (imgRow === noImage ? "noImage" : "")}>
Expand Down
2 changes: 0 additions & 2 deletions src/common/components/entry-list-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { getPost } from "../../api/bridge";
import "./_index.scss";
import useMountedState from "react-use/lib/useMountedState";
import { useMappedStore } from "../../store/use-mapped-store";
import { useLocation } from "react-router";
import useMount from "react-use/lib/useMount";
import { useUnmount } from "react-use";
import { Community } from "../../store/communities";
Expand Down Expand Up @@ -67,7 +66,6 @@ export function EntryListItem({
const [showMuted, setShowMuted] = useState(mutedProp);
const [showModMuted, setShowModMuted] = useState(false);

const location = useLocation();
const { global, activeUser, addAccount, updateEntry } = useMappedStore();

const isMounted = useMountedState();
Expand Down