resolving promise reject when async storage is null (#45)

Co-authored-by: Gustavo Emanuel Farias Rosa <gustavoemanuelfariasrosa@Mac-mini-de-Gustavo.local>
This commit is contained in:
Gustavo Emanuel Farias Rosa 2022-06-20 08:40:15 -03:00 committed by GitHub
parent f01348c28a
commit c52d081e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,8 +51,22 @@ const DeepLink = ()=>{
}
async function checkIfHaveTemporaryPortal(){
const portalsFromStorage = await AsyncStorage.getItem('portal')
const portalsParsed = JSON.parse(portalsFromStorage)
let portalsParsed: IPortal[]|null = null;
try {
let items = await AsyncStorage.getAllKeys();
if (items.includes('portal')) {
const portalsFromStorage = await AsyncStorage.getItem('portal')
portalsParsed = portalsFromStorage ? JSON.parse(portalsFromStorage) : null
} else {
console.log('Error: Dont Have Portals Storage');
}
} catch (e) {
console.log('error', e);
}
if(!portalsParsed){
return
}
const portalsWithoutTemporary = portalsParsed.filter((portal: IPortal)=>{
if(portal.temporary == true) return false
if(portal.name == NAME_PORTALS_DEEP_LINK) return false