-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from himanshu8443/feature
fixed watchlist
- Loading branch information
Showing
7 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {create} from 'zustand'; | ||
import {MMKV} from '../Mmkv'; | ||
|
||
export interface WatchList { | ||
title: string; | ||
poster: string; | ||
link: string; | ||
provider: string; | ||
} | ||
|
||
interface WatchListStore { | ||
watchList: WatchList[]; | ||
removeItem: (link: string) => void; | ||
addItem: (item: WatchList) => void; | ||
// clearWatchList: () => void; | ||
} | ||
|
||
const useWatchListStore = create<WatchListStore>()(set => ({ | ||
watchList: JSON.parse(MMKV.getString('watchlist') || '[]'), | ||
removeItem: link => { | ||
const watchList = JSON.parse(MMKV.getString('watchlist') || '[]'); | ||
const newWatchList = watchList.filter((i: WatchList) => i.link !== link); | ||
MMKV.setString('watchlist', JSON.stringify(newWatchList)); | ||
set({watchList: newWatchList}); | ||
}, | ||
addItem: item => { | ||
const watchList = JSON.parse(MMKV.getString('watchlist') || '[]'); | ||
const newWatchList = watchList.filter( | ||
(i: WatchList) => i.link !== item.link, | ||
); | ||
newWatchList.push(item); | ||
MMKV.setString('watchlist', JSON.stringify(newWatchList)); | ||
set({watchList: newWatchList}); | ||
}, | ||
// clearWatchList: () => { | ||
// MMKV.setString('watchlist', '[]'); | ||
// set({watchList: []}); | ||
// }, | ||
})); | ||
|
||
export default useWatchListStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters