refactor: decouple lyrics providers from synced-lyrics#4267
refactor: decouple lyrics providers from synced-lyrics#4267Yumeo0 wants to merge 3 commits intopear-devs:masterfrom
Conversation
|
I am converting this to a draft PR so annoying copilot won't pollute the chat. You introduced a dependency system between plugins, you detect circular dependencies, among other stuff. Plus, if we are going to do a refactor of this scale, might as well implement a local lyrics database, to reduce our reliance on the lyrics providers being available. (and avoid rate-limits) So discussing it first is the way to go |
| (window as any).lyricsProvider = { | ||
| fetchLyrics, | ||
| currentLyrics, | ||
| lyricsStore, | ||
| setLyricsStore, | ||
| retrySearch, | ||
| }; |
There was a problem hiding this comment.
I would be in favour of introducing a dependency injection container for such needs.
My personal favorite is di-wise
I'm gonna comment on everything else later but I just quickly wanted to say that this is absolutely out of scope for what this PR is supposed to do. I only copy pastes the code from synced-lyrics into the new plugin. I didn't change the underlying logic at all. If somebody wants to add a local lyrics database in a new PR they can feel free to do so. |
I may have been too ambiguous, by "database" I meant having a local .json file or smth that "caches" the lyrics across app restarts. Currently we store them in memory, and only keep them cached for the lifetime of the session.
|
Topological Sort The Global API exposure via Providing the lyrics |
This splits the actual lyric fetching from the lyrics displaying.
I thought it was logical to split out the lyrics-provider when I worked on the better-fullscreen plugin because fetching the lyrics multiple times seemed stupid. So I create the lyrics-provider plugin and a way for other plugins to depend on it.
This PR also rewrites the synced-lyrics plugin to use the new lyrics-provider.