Skip to content

Commit

Permalink
organize readings better on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowySailor authored and m-wynn committed Dec 28, 2024
1 parent ec3e72b commit c00d560
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/(application)/Bookshelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import Shelf from './Shelf';
import { useGlobalContext } from './GlobalContext';
import { updateReadingStatus, removeReading } from './functions';

function compareReadings(a: Reading, b: Reading) {
return a.volume.series.englishName.localeCompare(b.volume.series.englishName)
|| a.volume.number - b.volume.number;
}

function Bookshelf() {
const { allReadings, setAllReadings, userSettings } = useGlobalContext();

Expand All @@ -24,19 +29,19 @@ function Bookshelf() {
const inProgress = useMemo(
() => allReadings.filter(
(reading) => reading.status === 'READING' && canUserSeeIfNsfw(reading),
) as unknown as Reading[],
).sort(compareReadings) as unknown as Reading[],
[allReadings, canUserSeeIfNsfw],
);
const unread = useMemo(
() => allReadings.filter(
(reading) => reading.status === 'UNREAD' && canUserSeeIfNsfw(reading),
) as unknown as Reading[],
).sort(compareReadings) as unknown as Reading[],
[allReadings, canUserSeeIfNsfw],
);
const read = useMemo(
() => allReadings.filter(
(reading) => reading.status === 'READ' && canUserSeeIfNsfw(reading),
) as unknown as Reading[],
).sort(compareReadings) as unknown as Reading[],
[allReadings, canUserSeeIfNsfw],
);

Expand Down

0 comments on commit c00d560

Please sign in to comment.