Skip to content

Commit

Permalink
feat: remove feedis setting in store
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaDraganJW committed May 5, 2023
1 parent 1e4bb25 commit b8200ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 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, useConfigStore } from '#src/stores/ConfigStore';
import { PersonalShelf } from '#src/stores/ConfigStore';
import type { Playlist, PlaylistItem } from '#types/playlist';

type FavoritesState = {
Expand All @@ -19,12 +19,10 @@ 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: () => {
const features = useConfigStore((s) => s.config.features);
return {
feedid: features?.favoritesList || PersonalShelf.Favorites,
getPlaylist: () =>
({
feedid: PersonalShelf.Favorites,
title: 'Favorites',
playlist: get().favorites.map(({ playlistItem }) => playlistItem),
} as Playlist;
},
} as Playlist),
}));
12 changes: 5 additions & 7 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, useConfigStore } from '#src/stores/ConfigStore';
import { PersonalShelf } from '#src/stores/ConfigStore';
import type { WatchHistoryItem } from '#types/watchHistory';
import type { Playlist, PlaylistItem } from '#types/playlist';

Expand All @@ -20,16 +20,14 @@ export const useWatchHistoryStore = createStore<WatchHistoryState>('WatchHistory
get().watchHistory.find(({ mediaid, progress }) => {
return mediaid === item.mediaid && progress > VideoProgressMinMax.Min && progress < VideoProgressMinMax.Max;
}),
getPlaylist: () => {
const features = useConfigStore((s) => s.config.features);
return {
feedid: features?.continueWatchingList || PersonalShelf.ContinueWatching,
getPlaylist: () =>
({
feedid: 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 b8200ad

Please sign in to comment.