Skip to content

Commit

Permalink
feat: improves parse posts function for albums
Browse files Browse the repository at this point in the history
  • Loading branch information
malcodeman committed Nov 18, 2024
1 parent e7eab4a commit a27e707
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/_lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RedditPost, RedditComment } from "@/types";
import { parse } from "path";
import { and, equals, filter, includes, isNotNil, replace } from "ramda";
import { all, and, equals, filter, includes, or, replace, values } from "ramda";
import {
SUPPORTED_FILE_EXTENSIONS,
SUPPORTED_VIDEO_EXTENSIONS,
Expand Down Expand Up @@ -37,10 +37,15 @@ export const parsePost = (post: RedditPost): RedditPost => {
export const parsePosts = (posts: RedditPost[]) => {
return filter(
(item) =>
includes(getExtension(item.data.url), SUPPORTED_FILE_EXTENSIONS) ||
and(
equals(item.data.is_gallery, true),
isNotNil(item.data.media_metadata),
or(
includes(getExtension(item.data.url), SUPPORTED_FILE_EXTENSIONS),
and(
equals(item.data.is_gallery, true),
all(
(item) => equals(item.status, "valid"),
values(item.data.media_metadata ?? {}),
),
),
),
posts,
);
Expand Down

0 comments on commit a27e707

Please sign in to comment.