Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
1e6ae1ec
Commit
1e6ae1ec
authored
Sep 10, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image caching seems to be functionnal but require more test
parent
2dc5409d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
UserAuthenticationContext.tsx
src/contexts/UserAuthenticationContext.tsx
+2
-0
assetsCache.tsx
src/utils/assetsCache.tsx
+35
-0
No files found.
src/contexts/UserAuthenticationContext.tsx
View file @
1e6ae1ec
import
{
loadAssetsAsync
}
from
"@/utils/assetsCache"
;
import
authenticateUser
,
{
parseAuthicationErrors
}
from
"@/utils/requests/authenticateUser"
;
import
authenticateUser
,
{
parseAuthicationErrors
}
from
"@/utils/requests/authenticateUser"
;
import
type
{
IuserInformations
}
from
"@/utils/requests/types"
;
import
type
{
IuserInformations
}
from
"@/utils/requests/types"
;
import
getUserInformations
,
{
import
getUserInformations
,
{
...
@@ -234,6 +235,7 @@ export const UserAuthenticationContextProvider = ({ children }: { children: Reac
...
@@ -234,6 +235,7 @@ export const UserAuthenticationContextProvider = ({ children }: { children: Reac
log
.
debug
(
"UserAuthenticationContext | App Startup | loading saved user data."
);
log
.
debug
(
"UserAuthenticationContext | App Startup | loading saved user data."
);
(
async
()
=>
{
(
async
()
=>
{
try
{
try
{
await
loadAssetsAsync
();
const
authenticationData
=
await
loadAuthenticationData
();
const
authenticationData
=
await
loadAuthenticationData
();
const
userInformations
=
await
loadUserInformations
();
const
userInformations
=
await
loadUserInformations
();
if
(
authenticationData
&&
userInformations
)
{
if
(
authenticationData
&&
userInformations
)
{
...
...
src/utils/assetsCache.tsx
0 → 100644
View file @
1e6ae1ec
// To load assets asynchronously
import
{
Asset
}
from
"expo-asset"
;
import
{
LOG
}
from
"@logger"
;
const
log
=
LOG
.
extend
(
"assetsCache"
);
const
PATH_TO_ASSETS_FOLDER
=
"../../assets"
;
const
IMAGE_TO_CACHE
=
[
require
(
"../../assets/beasy_icon.png"
),
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_splash.png`
),
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_default.png`
),
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_background.png`
),
];
const
cacheImages
=
()
=>
{
return
IMAGE_TO_CACHE
.
map
((
image
)
=>
{
log
.
verbose
(
"cacheImages |"
,
image
);
return
Asset
.
fromModule
(
image
).
downloadAsync
();
});
};
export
const
cacheAssetsAsync
=
()
=>
{
return
Promise
.
all
([...
cacheImages
()]);
};
export
const
loadAssetsAsync
=
async
()
=>
{
try
{
await
cacheAssetsAsync
();
}
catch
(
error
)
{
log
.
error
(
"loadAssetsAsync |"
,
error
);
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment