wrapped optional login items in try catch

This commit is contained in:
noumantahir 2022-05-15 13:52:22 +05:00
parent 6d5926d60a
commit 52e6429127
3 changed files with 43 additions and 18 deletions

View File

@ -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 {

View File

@ -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));

View File

@ -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));