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
173fa7be
Commit
173fa7be
authored
Sep 10, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a different caching approach. Will modify it later.
parent
1fb8a252
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
35 deletions
+30
-35
UserAuthenticationContext.tsx
src/contexts/UserAuthenticationContext.tsx
+11
-2
assetsCache.tsx
src/utils/assetsCache.tsx
+19
-33
No files found.
src/contexts/UserAuthenticationContext.tsx
View file @
173fa7be
import
{
loadAssetsAsync
}
from
"@/utils/assetsCache"
;
import
cacheAssetsAsync
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
,
{
...
@@ -235,7 +235,16 @@ export const UserAuthenticationContextProvider = ({ children }: { children: Reac
...
@@ -235,7 +235,16 @@ 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
();
// await loadAssetsAsync();
await
cacheAssetsAsync
({
images
:
[
"../assets/background_default.png"
,
"../assets/beasy_default.png"
,
"../assets/beasy_background.png"
,
"../assets/background_content_white2.png"
,
"../../assets/background.png"
,
],
});
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
View file @
173fa7be
...
@@ -6,36 +6,22 @@ import { LOG } from "@logger";
...
@@ -6,36 +6,22 @@ import { LOG } from "@logger";
const
log
=
LOG
.
extend
(
"assetsCache"
);
const
log
=
LOG
.
extend
(
"assetsCache"
);
const
PATH_TO_ASSETS_FOLDER
=
"../../assets"
;
export
default
function
cacheAssetsAsync
({
images
=
[],
const
IMAGE_TO_CACHE
=
[
fonts
=
[],
require
(
"../../assets/beasy_icon.png"
),
videos
=
[],
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_splash.png`
),
}:
{
images
?:
string
[];
fonts
?:
string
[];
videos
?:
string
[]
})
{
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_default.png`
),
return
Promise
.
all
([...
cacheImages
(
images
)]);
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/beasy_background.png`
),
}
// Operators
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/operators/orange_money.png`
),
function
cacheImages
(
images
:
string
[])
{
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/operators/mtn_money.png`
),
return
images
.
map
((
image
)
=>
Asset
.
fromModule
(
image
).
downloadAsync
());
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/operators/moov_money.png`
),
}
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/operators/wave_money.png`
),
require
(
`
${
PATH_TO_ASSETS_FOLDER
}
/operators/visa_card.png`
),
// function cacheVideos(videos) {
];
// return videos.map((video) => Asset.fromModule(video).downloadAsync());
// }
const
cacheImages
=
()
=>
{
return
IMAGE_TO_CACHE
.
map
((
image
)
=>
{
// function cacheFonts(fonts) {
log
.
verbose
(
"cacheImages |"
,
image
);
// return fonts.map((font) => Font.loadAsync(font));
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