Move download status subscription to "ChapterCard"
Only re-render chapters whose download status has changed instead of the whole list everytime a download status change was received
This commit is contained in:
@@ -30,7 +30,7 @@ import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
||||
|
||||
export const ChapterUpdateCard = ({ chapter }: { chapter: ChapterUpdateListFieldsFragment }) => {
|
||||
const { manga } = chapter;
|
||||
const download = Chapters.getDownloadStatusFromCache(chapter.id);
|
||||
const download = Chapters.useDownloadStatusFromCache(chapter.id);
|
||||
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
@@ -112,7 +112,7 @@ export const ChapterUpdateCard = ({ chapter }: { chapter: ChapterUpdateListField
|
||||
</TypographyMaxLines>
|
||||
</Box>
|
||||
</Box>
|
||||
{download && <DownloadStateIndicator download={download} />}
|
||||
<DownloadStateIndicator chapterId={chapter.id} />
|
||||
{download?.state === DownloadState.Error && (
|
||||
<Tooltip title={t('global.button.retry')}>
|
||||
<IconButton
|
||||
|
||||
@@ -58,8 +58,6 @@ export const Updates: React.FC = () => {
|
||||
const groupedUpdates = useMemo(() => groupByDate(updateEntries), [updateEntries]);
|
||||
const groupCounts: number[] = useMemo(() => groupedUpdates.map((group) => group[1]), [groupedUpdates]);
|
||||
|
||||
requestManager.useDownloadSubscription();
|
||||
|
||||
const computeItemKey = VirtuosoUtil.useCreateGroupedComputeItemKey(
|
||||
groupCounts,
|
||||
useCallback((index) => groupedUpdates[index][0], [groupedUpdates]),
|
||||
|
||||
Reference in New Issue
Block a user