Untitled
unknown
plain_text
a year ago
3.6 kB
2
Indexable
Never
import AsyncStorage from '@react-native-async-storage/async-storage'; /** * @param {Array} markers * markers state from MapView.js ** Updates storage with key 'Markers' and value markers */ export const addMarkersToStorage = async markers => { try { await AsyncStorage.setItem('Markers', JSON.stringify(markers)); } catch (error) { console.log('errror', error); } }; export const addPinsToStorage = async arrayOfPins => { try { await AsyncStorage.setItem('Pins', JSON.stringify(arrayOfPins)); } catch (error) { console.log('Failed to add pins to storage due to error:', error); } }; export const getPinsFromStorage = async () => { try { const pins = await AsyncStorage.getItem('Pins'); if (pins !== null) { return JSON.parse(pins); } } catch (error) { console.log('Error while trying to get pins from storage. Error:', error); } }; export const getMarkersFromStorage = async () => { try { const data = await AsyncStorage.getItem('Markers'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } }; export const addMapboxCLToStorage = async mapboxCL => { try { await AsyncStorage.setItem('MapboxCL', JSON.stringify(mapboxCL)); } catch (error) { console.log('errror', error); } }; export const getMapboxCLFromStorage = async () => { try { const data = await AsyncStorage.getItem('MapboxCL'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } }; export const addCLToStorage = async mapboxCL => { try { await AsyncStorage.setItem('CL', JSON.stringify(mapboxCL)); } catch (error) { console.log('errror', error); } }; export const getCLFromStorage = async () => { try { const data = await AsyncStorage.getItem('CL'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } }; export const getInterestsFromStorage = async () => { try { const data = await AsyncStorage.getItem('Interests'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } }; export const addInterestsToStorage = async interests => { try { await AsyncStorage.setItem('Interests', JSON.stringify(interests)); } catch (error) { console.log('errror', error); } }; export const cleanInterestsFromStorage = async () => { try { await AsyncStorage.removeItem('Interests'); } catch (error) { console.log('errror', error); } }; export const getEventsFromStorage = async () => { try { const data = await AsyncStorage.getItem('Events'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } }; export const addEventsToStorage = async events => { try { await AsyncStorage.setItem('Events', JSON.stringify(events)); } catch (error) { console.log('errror', error) } } export const addUserLocationToStorage= async events => { try { await AsyncStorage.setItem('UserLocation', JSON.stringify(events)); } catch (error) { console.log('errror', error) } } export const getUserLocationFromStorage= async () => { try { const data = await AsyncStorage.getItem('UserLocation'); if (data !== null) { return JSON.parse(data); } } catch (error) { console.log('Error: ', error); } };