Skip to content

Commit

Permalink
feat: change feedid for favorites and continue watching to match the …
Browse files Browse the repository at this point in the history
…playlist id from config file
  • Loading branch information
CarinaDraganJW committed May 3, 2023
1 parent ce3abff commit a63329a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/stores/FavoritesStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createStore } from './utils';

import type { Favorite } from '#types/favorite';
import { PersonalShelf } from '#src/stores/ConfigStore';
import { PersonalShelf, useConfigStore } from '#src/stores/ConfigStore';
import type { Playlist, PlaylistItem } from '#types/playlist';

type FavoritesState = {
Expand All @@ -19,10 +19,12 @@ export const useFavoritesStore = createStore<FavoritesState>('FavoritesState', (
setWarning: (message: string | null) => set({ warning: message }),
clearWarning: () => set({ warning: null }),
hasItem: (item: PlaylistItem) => get().favorites.some((favoriteItem) => favoriteItem.mediaid === item.mediaid),
getPlaylist: () =>
({
feedid: PersonalShelf.Favorites,
getPlaylist: () => {
const features = useConfigStore((s) => s.config.features);
return {
feedid: features?.favoritesList || PersonalShelf.Favorites,
title: 'Favorites',
playlist: get().favorites.map(({ playlistItem }) => playlistItem),
} as Playlist),
} as Playlist;
},
}));
12 changes: 7 additions & 5 deletions src/stores/WatchHistoryStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createStore } from './utils';

import { VideoProgressMinMax } from '#src/config';
import { PersonalShelf } from '#src/stores/ConfigStore';
import { PersonalShelf, useConfigStore } from '#src/stores/ConfigStore';
import type { WatchHistoryItem } from '#types/watchHistory';
import type { Playlist, PlaylistItem } from '#types/playlist';

Expand All @@ -20,14 +20,16 @@ export const useWatchHistoryStore = createStore<WatchHistoryState>('WatchHistory
get().watchHistory.find(({ mediaid, progress }) => {
return mediaid === item.mediaid && progress > VideoProgressMinMax.Min && progress < VideoProgressMinMax.Max;
}),
getPlaylist: () =>
({
feedid: PersonalShelf.ContinueWatching,
getPlaylist: () => {
const features = useConfigStore((s) => s.config.features);
return {
feedid: features?.continueWatchingList || PersonalShelf.ContinueWatching,
title: 'Continue watching',
playlist: get()
.watchHistory.filter(({ playlistItem, progress }) => !!playlistItem && progress > VideoProgressMinMax.Min && progress < VideoProgressMinMax.Max)
.map(({ playlistItem }) => playlistItem),
} as Playlist),
} as Playlist;
},
getDictionary: () =>
get().watchHistory.reduce((dict: { [key: string]: number }, item) => {
dict[item.mediaid] = item.progress;
Expand Down

0 comments on commit a63329a

Please sign in to comment.