Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Mobile
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
244
Merge Requests
13
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Compare Revisions
9390afacc5a2eef9a6498de242251b423e66d605...95e9bdf0f4788cbdbd1e46798bdfc1f38585ed8a
Source
95e9bdf0f4788cbdbd1e46798bdfc1f38585ed8a
...
Target
9390afacc5a2eef9a6498de242251b423e66d605
Compare
Commits (2)
(feat) optimize app init speed
· 10c3b3c7
Martin Santangelo
authored
4 hours ago
10c3b3c7
Merge branch 'feat/optimize-init-speed-app' into 'release/3.11.0'
· 95e9bdf0
Martin Santangelo
authored
15 minutes ago
Optimize app init speed See merge request
!407
95e9bdf0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
37 deletions
+45
-37
App.js
View file @
95e9bdf0
...
...
@@ -81,8 +81,9 @@ sessionService.onLogin(async () => {
});
logService
.
info
(
'
[App] Getting minds settings and onboarding progress
'
);
// load minds settings and onboarding progresss on login
const
results
=
await
Promise
.
all
([
mindsService
.
getSettings
(),
stores
.
onboarding
.
getProgress
(),
boostedContentService
.
load
()]);
// load minds settings and boosted content
await
Promise
.
all
([
mindsService
.
getSettings
(),
boostedContentService
.
load
()]);
logService
.
info
(
'
[App] updatting features
'
);
// reload fatures on login
...
...
@@ -92,16 +93,12 @@ sessionService.onLogin(async () => {
pushService
.
registerToken
();
// get onboarding progress
const
onboarding
=
results
[
1
];
if
(
onboarding
&&
onboarding
.
show_onboarding
)
{
sessionService
.
setInitialScreen
(
'
OnboardingScreen
'
);
}
logService
.
info
(
'
[App] navigating to initial screen
'
,
sessionService
.
initialScreen
);
NavigationService
.
navigate
(
sessionService
.
initialScreen
);
// check onboarding progress and navigate if necessary
stores
.
onboarding
.
getProgress
();
// check update
if
(
Platform
.
OS
!==
'
ios
'
&&
!
GOOGLE_PLAY_STORE
)
{
setTimeout
(
async
()
=>
{
...
...
@@ -199,8 +196,9 @@ export default class App extends Component<Props, State> {
*/
async
componentDidMount
()
{
try
{
// load app setting before start
const
results
=
await
Promise
.
all
([
settingsStore
.
init
(),
await
Linking
.
getInitialURL
()])
,
const
results
=
await
Promise
.
all
([
settingsStore
.
init
(),
await
Linking
.
getInitialURL
()])
;
deepLinkUrl
=
results
[
1
];
...
...
@@ -210,6 +208,7 @@ export default class App extends Component<Props, State> {
if
(
!
this
.
handlePasswordResetDeepLink
())
{
logService
.
info
(
'
[App] initializing session
'
);
const
token
=
await
sessionService
.
init
();
if
(
!
token
)
{
...
...
This diff is collapsed.
__tests__/common/services/boosted-content.service.js
View file @
95e9bdf0
...
...
@@ -14,6 +14,7 @@ describe('Boosted content service', () => {
const
fakeBoosts
=
[{
guid
:
1
},
{
guid
:
2
},
{
guid
:
3
}];
boostedContentService
.
feedsService
.
getEntities
.
mockResolvedValue
(
fakeBoosts
);
boostedContentService
.
feedsService
.
fetchLocal
.
mockResolvedValue
(
true
);
// load the boosts
await
boostedContentService
.
load
();
...
...
@@ -22,7 +23,7 @@ describe('Boosted content service', () => {
expect
(
boostedContentService
.
feedsService
.
setEndpoint
).
toBeCalledWith
(
'
api/v2/boost/feed
'
);
expect
(
boostedContentService
.
feedsService
.
setOffset
).
toBeCalledWith
(
0
);
expect
(
boostedContentService
.
feedsService
.
setLimit
).
toBeCalledWith
(
12
);
expect
(
boostedContentService
.
feedsService
.
fetch
RemoteOr
Local
).
toBeCalled
();
expect
(
boostedContentService
.
feedsService
.
fetchLocal
).
toBeCalled
();
// should fetch the boosts entities
expect
(
boostedContentService
.
feedsService
.
getEntities
).
toBeCalled
();
...
...
This diff is collapsed.
src/common/services/boosted-content.service.js
View file @
95e9bdf0
...
...
@@ -21,19 +21,34 @@ class BoostedContentService {
*/
load
=
async
():
Promise
<
any
>
=>
{
try
{
await
this
.
feedsService
const
done
=
await
this
.
feedsService
.
setLimit
(
12
)
.
setOffset
(
0
)
.
setPaginated
(
false
)
.
setEndpoint
(
'
api/v2/boost/feed
'
)
.
fetchRemoteOrLocal
();
.
fetchLocal
();
if
(
!
done
)
{
await
this
.
update
();
}
else
{
this
.
boosts
=
await
this
.
feedsService
.
getEntities
();
// refresh boost without the wait
this
.
update
();
}
this
.
boosts
=
await
this
.
feedsService
.
getEntities
();
}
catch
(
err
)
{
logService
.
exception
(
'
[BoostedContentService]
'
,
err
);
}
}
/**
* Update boosted content from server
*/
async
update
()
{
await
this
.
feedsService
.
fetchRemote
();
this
.
boosts
=
await
this
.
feedsService
.
getEntities
();
}
/**
* Fetch one boost
*/
...
...
This diff is collapsed.
src/common/services/minds.service.js
View file @
95e9bdf0
...
...
@@ -14,6 +14,12 @@ class MindsService {
*/
loadDefault
=
()
=>
require
(
"
../../../settings/default.json
"
);
async
update
()
{
const
settings
=
await
api
.
get
(
'
api/v1/minds/config
'
);
AsyncStorage
.
setItem
(
'
@MindsSettings
'
,
JSON
.
stringify
(
settings
));
this
.
settings
=
this
.
settings
;
}
/**
* Get settings
*/
...
...
@@ -21,31 +27,14 @@ class MindsService {
let
settings
;
if
(
!
this
.
settings
)
{
try
{
settings
=
await
api
.
get
(
'
api/v1/minds/config
'
);
settings
=
JSON
.
parse
(
await
AsyncStorage
.
getItem
(
'
@MindsSettings
'
));
if
(
!
settings
)
throw
Error
(
'
No settings stored
'
);
}
catch
{
settings
=
this
.
loadDefault
();
AsyncStorage
.
setItem
(
'
@MindsSettings
'
,
JSON
.
stringify
(
settings
));
}
catch
(
err
)
{
try
{
settings
=
JSON
.
parse
(
await
AsyncStorage
.
getItem
(
'
@MindsSettings
'
));
if
(
!
settings
)
throw
Error
(
'
No settings stored
'
);
}
catch
{
settings
=
this
.
loadDefault
();
AsyncStorage
.
setItem
(
'
@MindsSettings
'
,
JSON
.
stringify
(
settings
));
}
}
if
(
settings
)
{
this
.
settings
=
settings
;
}
else
{
return
await
new
Promise
(
resolve
=>
{
Alert
.
alert
(
i18n
.
t
(
'
error
'
),
i18n
.
t
(
'
mindsSettings.error
'
),
[
{
text
:
i18n
.
t
(
'
retry
'
),
onPress
:
async
()
=>
resolve
(
await
this
.
getSettings
())
}
]
);
});
}
this
.
settings
=
settings
;
this
.
update
();
}
return
this
.
settings
;
...
...
This diff is collapsed.
src/onboarding/OnboardingStore.js
View file @
95e9bdf0
...
...
@@ -4,6 +4,7 @@ import number from '../common/helpers/number';
import
OffsetListStore
from
'
../common/stores/OffsetListStore
'
;
import
logService
from
'
../common/services/log.service
'
;
import
UserModel
from
'
../channel/UserModel
'
;
import
NavigationService
from
'
../navigation/NavigationService
'
;
/**
* Onboarding store
...
...
@@ -36,6 +37,9 @@ class OnboardingStore {
try
{
const
progress
=
await
onboardingService
.
getProgress
();
this
.
setProgress
(
progress
);
if
(
progress
&&
progress
.
show_onboarding
)
{
NavigationService
.
push
(
'
OnboardingScreen
'
);
}
return
progress
;
}
catch
(
err
)
{
logService
.
exception
(
err
);
...
...
This diff is collapsed.