From 1173480fd93a56fa60333c01ffc70b67db82826a Mon Sep 17 00:00:00 2001
From: piotrruss <mail@pruss.it>
Date: Sun, 22 May 2022 18:11:30 +0100
Subject: added loader

---
 utils/helpers.jsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'utils/helpers.jsx')

diff --git a/utils/helpers.jsx b/utils/helpers.jsx
index 9e130dc..62d740c 100644
--- a/utils/helpers.jsx
+++ b/utils/helpers.jsx
@@ -2,7 +2,8 @@ import AsyncStorage from '@react-native-async-storage/async-storage'
 import { Alert } from 'react-native';
 import { login, getNote, editNote, createNote, removeNote } from './api'
 
-export const handleLogin = async ({ email, password, setSession, showError }) => {
+export const handleLogin = async ({ email, password, setSession, setLoading, showError }) => {
+  setLoading(true)
   try {
     const response = await login({ email, password })
     const cookies = response.headers?.map?.['set-cookie']
@@ -12,6 +13,7 @@ export const handleLogin = async ({ email, password, setSession, showError }) =>
       setSession({ ...data, cookies })
     }
   } catch(e) {
+    setLoading(false)
     showError('Error while logging in')
   }
 }
-- 
cgit v1.2.3

