Code Smell Corrections
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
2a5e43ded9
commit
ef5c4f1eb1
@ -1,47 +1,68 @@
|
|||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||||
import Movie from "../model/Movie";
|
import Movie from "../model/Movie"
|
||||||
import {useDispatch, useSelector} from "react-redux";
|
|
||||||
|
|
||||||
export const getFavouriteList = async () => {
|
export const getFavouriteList = async () => {
|
||||||
try {
|
try {
|
||||||
const value = await AsyncStorage.getItem('favourite');
|
const value = await AsyncStorage.getItem('favourite');
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
return [];
|
return null
|
||||||
}
|
}
|
||||||
const favouriteList: Movie[] = await JSON.parse(value!)
|
const favouriteList: Movie[] = await JSON.parse(value!)
|
||||||
return favouriteList;
|
return favouriteList
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return [];
|
return null
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export const setFavouriteList = async (favouriteList: Movie[]) => {
|
export const setFavouriteList = async (favouriteList: Movie[]) => {
|
||||||
try {
|
try {
|
||||||
await AsyncStorage.setItem('favourite', JSON.stringify(favouriteList));
|
await AsyncStorage.setItem('favourite', JSON.stringify(favouriteList))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export const getWatchLaterList = async () => {
|
export const getWatchLaterList = async () => {
|
||||||
try {
|
try {
|
||||||
const value = await AsyncStorage.getItem('watchLater');
|
const value = await AsyncStorage.getItem('watchLater')
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
return [];
|
return null
|
||||||
}
|
}
|
||||||
const watchLaterList: Movie[] = await JSON.parse(value!)
|
const watchLaterList: Movie[] = await JSON.parse(value!)
|
||||||
return watchLaterList;
|
return watchLaterList
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return [];
|
return null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setWatchLaterList = async (watchLaterList: Movie[]) => {
|
export const setWatchLaterList = async (watchLaterList: Movie[]) => {
|
||||||
try {
|
try {
|
||||||
await AsyncStorage.setItem('watchLater', JSON.stringify(watchLaterList));
|
await AsyncStorage.setItem('watchLater', JSON.stringify(watchLaterList))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export const getMovieList = async () => {
|
||||||
|
try {
|
||||||
|
const value = await AsyncStorage.getItem('movie')
|
||||||
|
if (value === null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const movieList: Movie[] = await JSON.parse(value!)
|
||||||
|
return movieList
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setMovieList = async (movieList: Movie[]) => {
|
||||||
|
try {
|
||||||
|
await AsyncStorage.setItem('movie', JSON.stringify(movieList))
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue