Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalized trackers refactor (+AniList) #631

Merged
merged 14 commits into from
May 14, 2023

Conversation

TehNut
Copy link

@TehNut TehNut commented May 11, 2023

Closes #42 (Example videos can be found in the replies)

Refactors the tracker system to be normalized for easy support of many different trackers. User data is migrated to the new data format when they launch the app for the first time since this update.

This was designed mostly with MyAnimeList and AniList in mind, but should be applicable to other trackers as well.

I tested everything I can think of, but I'm not a MAL user (and MAL is dead at the time of opening this PR 🙄) so it could definitely use a once over by another set of eyes. The data migration part could definitely use a solid test.

The MalTopNovels and AniListTopNovels components can probably be normalized as well, but I'm no React guy so I'm not sure how to "correctly" compose those.

I did not go through and add typing to most of the tracker store, but the new storage model looks like this:

import type {
  AuthenticationResult,
  SearchResult,
  TrackerName,
  UserListEntry,
} from 'src/services/Trackers';

type Tracker = {
  /** The name of this tracker */
  name: TrackerName;
  /** The authentication data */
  auth: AuthenticationResult;
};

type TrackedNovel = Pick<SearchResult, 'id' | 'totalChapters'> & {
  /** The internal LNReader ID */
  novelId: number;
  /** User specific list data */
  userData: UserListEntry;
};

type TrackerReducer = {
  tracker: Tracker;
  trackedNovels: TrackedNovel[];
};

TehNut added 14 commits May 6, 2023 01:29
Mostly functional. Many large, sweeping changes to the data model used, so it may be worth looking into migrating the existing data structures. Otherwise it's a bad time for people already using MAL to track.

Much of the data model is documented with JSDoc, mostly for my sanity. I've never used JSDoc before so idk how correct these defs are 🤷

MAL has been mostly migrated over to the new format. There's a few straggling bits that seem to reference the old code that need to be cleared out.

Things to do:

* Status selector needs to respect AniList values/options when AL is in use
* Rating selector should respect the user's chosen rating format
* AniList option in the Discover section
Fixes issues where things are initialized in the wrong order
MAL is effectively unchanged
AL supports all available formats. The UI leaves a bit to be desired, but it's functional.
Additional cleanup pass
@rajarsheechatterjee
Copy link
Member

Tested MAL, LGTM.

@rajarsheechatterjee rajarsheechatterjee merged commit 135712c into LNReader:main May 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Add Anilist
2 participants