mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 20:31:37 +03:00
wrapped optional login items in try catch
This commit is contained in:
parent
6d5926d60a
commit
52e6429127
@ -68,10 +68,14 @@ export const login = async (username, password, isPinCodeOpen) => {
|
||||
const code = await makeHsCode(account.name, signerPrivateKey);
|
||||
const scTokens = await getSCAccessToken(code);
|
||||
|
||||
try {
|
||||
const accessToken = scTokens?.access_token;
|
||||
account.unread_activity_count = await getUnreadNotificationCount(accessToken);
|
||||
account.pointsSummary = await getPointsSummary(account.username);
|
||||
account.mutes = await getMutes(account.username);
|
||||
} catch (err) {
|
||||
console.warn('Optional user data fetch failed, account can still function without them', err);
|
||||
}
|
||||
|
||||
let jsonMetadata;
|
||||
try {
|
||||
@ -134,10 +138,14 @@ export const loginWithSC2 = async (code, isPinCodeOpen) => {
|
||||
let avatar = '';
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const accessToken = scTokens ? scTokens.access_token : '';
|
||||
account.unread_activity_count = await getUnreadNotificationCount(accessToken);
|
||||
account.pointsSummary = await getPointsSummary(account.username);
|
||||
account.mutes = await getMutes(account.username);
|
||||
} catch (err) {
|
||||
console.warn('Optional user data fetch failed, account can still function without them', err);
|
||||
}
|
||||
|
||||
let jsonMetadata;
|
||||
try {
|
||||
|
@ -775,9 +775,16 @@ class ApplicationContainer extends Component {
|
||||
accountData = await this._refreshAccessToken(accountData);
|
||||
}
|
||||
|
||||
try {
|
||||
accountData.unread_activity_count = await getUnreadNotificationCount();
|
||||
accountData.mutes = await getMutes(realmObject.username);
|
||||
accountData.pointsSummary = await getPointsSummary(realmObject.username);
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
'Optional user data fetch failed, account can still function without them',
|
||||
err,
|
||||
);
|
||||
}
|
||||
dispatch(updateCurrentAccount(accountData));
|
||||
dispatch(fetchSubscribedCommunities(realmObject.username));
|
||||
this._connectNotificationServer(accountData.name);
|
||||
@ -956,10 +963,13 @@ class ApplicationContainer extends Component {
|
||||
//update refresh token
|
||||
_currentAccount = await this._refreshAccessToken(_currentAccount);
|
||||
|
||||
//TODO decrypt access token here;
|
||||
try {
|
||||
_currentAccount.unread_activity_count = await getUnreadNotificationCount();
|
||||
_currentAccount.pointsSummary = await getPointsSummary(_currentAccount.username);
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
} catch (err) {
|
||||
console.warn('Optional user data fetch failed, account can still function without them', err);
|
||||
}
|
||||
|
||||
dispatch(updateCurrentAccount(_currentAccount));
|
||||
dispatch(fetchSubscribedCommunities(_currentAccount.username));
|
||||
|
@ -319,9 +319,16 @@ class PinCodeContainer extends Component {
|
||||
}
|
||||
|
||||
//get unread notifications
|
||||
try {
|
||||
_currentAccount.unread_activity_count = await getUnreadNotificationCount();
|
||||
_currentAccount.pointsSummary = await getPointsSummary(_currentAccount.username);
|
||||
_currentAccount.mutes = await getMutes(_currentAccount.username);
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
'Optional user data fetch failed, account can still function without them',
|
||||
err,
|
||||
);
|
||||
}
|
||||
|
||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||
dispatch(fetchSubscribedCommunities(_currentAccount.username));
|
||||
|
Loading…
Reference in New Issue
Block a user