Skip to content

Commit

Permalink
Add support for apollo favorites (aeharding#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding authored Jun 30, 2023
1 parent d2bf593 commit 2ef5f9d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/pages/settings/ApolloMigratePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,26 @@ export default function ApolloMigratePage() {
);
}

interface ApolloUserData {
subscribed_subreddits: string[];
favorites: string[];
}

async function getSubreddits(file: File): Promise<string[]> {
const dataByUser = Object.values(
await convertFileToJson(file)
) as ApolloUserData[];

return sortBy(
uniq(
flatten(
Object.values(await convertFileToJson(file)).map(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(user) => (user as any).subscribed_subreddits
)
dataByUser
.map((user) => user.subscribed_subreddits)
.concat(dataByUser.map((user) => user.favorites))
)
).filter(notEmpty),
identity
) as string[];
);
}

function convertFileToJson(file: File): Promise<never> {
Expand Down

0 comments on commit 2ef5f9d

Please sign in to comment.