Notifications: skip resolve during boot (#330)
## Issue - Large resolve count (albeit batched) on bootup. ## Changes - Skip the call on bootup. The same call will happen when you click the notification bell, so it's not too late to resolve at that time. - Added `true` to `doResolveUris` to return cached results, otherwise it will keep resolving the same channels every time we enter Notifications Page.
This commit is contained in:
parent
6a33ed337b
commit
328b60d021
2 changed files with 26 additions and 22 deletions
|
@ -545,7 +545,7 @@ export function doSignIn() {
|
|||
|
||||
dispatch(doGetAndPopulatePreferences());
|
||||
dispatch(doNotificationSocketConnect(true));
|
||||
dispatch(doNotificationList());
|
||||
dispatch(doNotificationList(null, false));
|
||||
dispatch(doCheckPendingClaims());
|
||||
dispatch(doBalanceSubscribe());
|
||||
dispatch(doFetchChannelListMine());
|
||||
|
|
|
@ -45,7 +45,7 @@ export function doDismissError() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doNotificationList(types?: Array<string>) {
|
||||
export function doNotificationList(types?: Array<string>, resolve: boolean = true) {
|
||||
return async (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const notificationTypes = selectNotificationCategories(state);
|
||||
|
@ -72,27 +72,31 @@ export function doNotificationList(types?: Array<string>) {
|
|||
|
||||
return Lbryio.call('notification', 'list', params).then((response) => {
|
||||
const notifications = response || [];
|
||||
const channelsToResolve = notifications
|
||||
.filter((notification: WebNotification) => {
|
||||
if (
|
||||
(notification.notification_parameters.dynamic &&
|
||||
notification.notification_parameters.dynamic.comment_author) ||
|
||||
notification.notification_rule === RULE.NEW_CONTENT
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.map((notification) => {
|
||||
if (notification.notification_rule === RULE.NEW_CONTENT) {
|
||||
return notification.notification_parameters.device.target;
|
||||
} else {
|
||||
return notification.notification_parameters.dynamic.comment_author;
|
||||
}
|
||||
});
|
||||
|
||||
dispatch(doResolveUris(channelsToResolve));
|
||||
if (resolve) {
|
||||
const channelsToResolve = notifications
|
||||
.filter((notification: WebNotification) => {
|
||||
if (
|
||||
(notification.notification_parameters.dynamic &&
|
||||
notification.notification_parameters.dynamic.comment_author) ||
|
||||
notification.notification_rule === RULE.NEW_CONTENT
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.map((notification) => {
|
||||
if (notification.notification_rule === RULE.NEW_CONTENT) {
|
||||
return notification.notification_parameters.device.target;
|
||||
} else {
|
||||
return notification.notification_parameters.dynamic.comment_author;
|
||||
}
|
||||
});
|
||||
|
||||
dispatch(doResolveUris(channelsToResolve, true));
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.NOTIFICATION_LIST_COMPLETED,
|
||||
data: {
|
||||
|
|
Loading…
Reference in a new issue