more notifications renaming
This commit is contained in:
parent
f532aa2566
commit
43dcb39045
9 changed files with 60 additions and 51 deletions
|
@ -1,6 +1,6 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
||||
import { doSeeAllNotifications } from 'redux/actions/notifications';
|
||||
import { doLbryioSeeAllNotifications } from 'redux/actions/notifications';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
import NotificationHeaderButton from './view';
|
||||
|
||||
|
@ -10,5 +10,5 @@ const select = (state) => ({
|
|||
});
|
||||
|
||||
export default connect(select, {
|
||||
doSeeAllNotifications,
|
||||
doLbryioSeeAllNotifications,
|
||||
})(NotificationHeaderButton);
|
||||
|
|
|
@ -14,17 +14,17 @@ import Tooltip from 'component/common/tooltip';
|
|||
type Props = {
|
||||
unseenCount: number,
|
||||
user: ?User,
|
||||
doSeeAllNotifications: () => void,
|
||||
doLbryioSeeAllNotifications: () => void,
|
||||
};
|
||||
|
||||
export default function NotificationHeaderButton(props: Props) {
|
||||
const { unseenCount, user, doSeeAllNotifications } = props;
|
||||
const { unseenCount, user, doLbryioSeeAllNotifications } = props;
|
||||
|
||||
const { push } = useHistory();
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
|
||||
function handleMenuClick() {
|
||||
if (unseenCount > 0) doSeeAllNotifications();
|
||||
if (unseenCount > 0) doLbryioSeeAllNotifications();
|
||||
push(`/$/${PAGES.NOTIFICATIONS}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { doReadNotifications, doDeleteNotification } from 'redux/actions/notifications';
|
||||
import { doLbryioNotificationsMarkRead, doLbryioDeleteNotification } from 'redux/actions/notifications';
|
||||
import Notification from './view';
|
||||
|
||||
const perform = (dispatch, ownProps) => ({
|
||||
readNotification: () => dispatch(doReadNotifications([ownProps.notification.id])),
|
||||
deleteNotification: () => dispatch(doDeleteNotification(ownProps.notification.id)),
|
||||
readNotification: () => dispatch(doLbryioNotificationsMarkRead([ownProps.notification.id])),
|
||||
deleteNotification: () => dispatch(doLbryioDeleteNotification(ownProps.notification.id)),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(Notification);
|
||||
|
|
|
@ -347,16 +347,16 @@ export const MEDIA_PAUSE = 'MEDIA_PAUSE';
|
|||
export const LBRYIO_NOTIFICATION_LIST_STARTED = 'NOTIFICATION_LIST_STARTED';
|
||||
export const LBRYIO_NOTIFICATION_LIST_COMPLETED = 'NOTIFICATION_LIST_COMPLETED';
|
||||
export const LBRYIO_NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED';
|
||||
export const NOTIFICATION_CATEGORIES_COMPLETED = 'NOTIFICATION_CATEGORIES_COMPLETED';
|
||||
export const NOTIFICATION_READ_STARTED = 'NOTIFICATION_READ_STARTED';
|
||||
export const NOTIFICATION_READ_COMPLETED = 'NOTIFICATION_READ_COMPLETED';
|
||||
export const NOTIFICATION_READ_FAILED = 'NOTIFICATION_READ_FAILED';
|
||||
export const NOTIFICATION_SEEN_STARTED = 'NOTIFICATION_SEEN_STARTED';
|
||||
export const NOTIFICATION_SEEN_COMPLETED = 'NOTIFICATION_SEEN_COMPLETED';
|
||||
export const NOTIFICATION_SEEN_FAILED = 'NOTIFICATION_SEEN_FAILED';
|
||||
export const NOTIFICATION_DELETE_STARTED = 'NOTIFICATION_DELETE_STARTED';
|
||||
export const NOTIFICATION_DELETE_COMPLETED = 'NOTIFICATION_DELETE_COMPLETED';
|
||||
export const NOTIFICATION_DELETE_FAILED = 'NOTIFICATION_DELETE_FAILED';
|
||||
export const LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED = 'LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED';
|
||||
export const LBRYIO_NOTIFICATION_READ_STARTED = 'LBRYIO_NOTIFICATION_READ_STARTED';
|
||||
export const LBRYIO_NOTIFICATION_READ_COMPLETED = 'LBRYIO_NOTIFICATION_READ_COMPLETED';
|
||||
export const LBRYIO_NOTIFICATION_READ_FAILED = 'LBRYIO_NOTIFICATION_READ_FAILED';
|
||||
export const LBRYIO_NOTIFICATION_SEEN_STARTED = 'LBRYIO_NOTIFICATION_SEEN_STARTED';
|
||||
export const LBRYIO_NOTIFICATION_SEEN_COMPLETED = 'LBRYIO_NOTIFICATION_SEEN_COMPLETED';
|
||||
export const LBRYIO_NOTIFICATION_SEEN_FAILED = 'LBRYIO_NOTIFICATION_SEEN_FAILED';
|
||||
export const LBRYIO_NOTIFICATION_DELETE_STARTED = 'LBRYIO_NOTIFICATION_DELETE_STARTED';
|
||||
export const LBRYIO_NOTIFICATION_DELETE_COMPLETED = 'LBRYIO_NOTIFICATION_DELETE_COMPLETED';
|
||||
export const LBRYIO_NOTIFICATION_DELETE_FAILED = 'LBRYIO_NOTIFICATION_DELETE_FAILED';
|
||||
export const CREATE_TOAST = 'CREATE_TOAST';
|
||||
export const DISMISS_TOAST = 'DISMISS_TOAST';
|
||||
export const CREATE_ERROR = 'CREATE_ERROR';
|
||||
|
|
|
@ -9,7 +9,11 @@ import {
|
|||
} from 'redux/selectors/notifications';
|
||||
import { doCommentReactList } from 'redux/actions/comments';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { doReadNotifications, doLbryioNotificationList, doSeeAllNotifications } from 'redux/actions/notifications';
|
||||
import {
|
||||
doLbryioNotificationsMarkRead,
|
||||
doLbryioNotificationList,
|
||||
doLbryioSeeAllNotifications,
|
||||
} from 'redux/actions/notifications';
|
||||
import NotificationsPage from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
|
@ -23,8 +27,8 @@ const select = (state) => ({
|
|||
});
|
||||
|
||||
export default connect(select, {
|
||||
doReadNotifications,
|
||||
doLbryioNotificationsMarkRead,
|
||||
doLbryioNotificationList,
|
||||
doSeeAllNotifications,
|
||||
doLbryioSeeAllNotifications,
|
||||
doCommentReactList,
|
||||
})(NotificationsPage);
|
||||
|
|
|
@ -19,8 +19,8 @@ type Props = {
|
|||
fetching: boolean,
|
||||
unreadCount: number,
|
||||
unseenCount: number,
|
||||
doSeeAllNotifications: () => void,
|
||||
doReadNotifications: () => void,
|
||||
doLbryioSeeAllNotifications: () => void,
|
||||
doLbryioNotificationsMarkRead: () => void,
|
||||
doLbryioNotificationList: (?Array<string>) => void,
|
||||
activeChannel: ?ChannelClaim,
|
||||
doCommentReactList: (Array<string>) => Promise<any>,
|
||||
|
@ -33,8 +33,8 @@ export default function NotificationsPage(props: Props) {
|
|||
fetching,
|
||||
unreadCount,
|
||||
unseenCount,
|
||||
doSeeAllNotifications,
|
||||
doReadNotifications,
|
||||
doLbryioSeeAllNotifications,
|
||||
doLbryioNotificationsMarkRead,
|
||||
doLbryioNotificationList,
|
||||
notificationCategories,
|
||||
activeChannel,
|
||||
|
@ -81,9 +81,9 @@ export default function NotificationsPage(props: Props) {
|
|||
|
||||
React.useEffect(() => {
|
||||
if (unseenCount > 0) {
|
||||
doSeeAllNotifications();
|
||||
doLbryioSeeAllNotifications();
|
||||
}
|
||||
}, [unseenCount, doSeeAllNotifications]);
|
||||
}, [unseenCount, doLbryioSeeAllNotifications]);
|
||||
|
||||
const stringifiedNotificationCategories = JSON.stringify(notificationCategories);
|
||||
React.useEffect(() => {
|
||||
|
@ -114,7 +114,12 @@ export default function NotificationsPage(props: Props) {
|
|||
{fetching && <Spinner type="small" />}
|
||||
|
||||
{unreadCount > 0 && (
|
||||
<Button icon={ICONS.EYE} onClick={doReadNotifications} button="secondary" label={__('Mark all as read')} />
|
||||
<Button
|
||||
icon={ICONS.EYE}
|
||||
onClick={doLbryioNotificationsMarkRead}
|
||||
button="secondary"
|
||||
label={__('Mark all as read')}
|
||||
/>
|
||||
)}
|
||||
{notificationCategories && (
|
||||
<FormField
|
||||
|
|
|
@ -7,7 +7,7 @@ import Lbry from 'lbry';
|
|||
import { parseURI, buildURI, isURIEqual } from 'util/lbryURI';
|
||||
import { selectClaimsByUri, selectMyChannelClaims } from 'redux/selectors/claims';
|
||||
import { doClaimSearch } from 'redux/actions/claims';
|
||||
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
|
||||
import { doToast, doLbryioNotificationsMarkSeen } from 'redux/actions/notifications';
|
||||
import {
|
||||
selectMyReactsForComment,
|
||||
selectOthersReactsForComment,
|
||||
|
@ -452,7 +452,7 @@ export function doCommentReact(commentId: string, type: string) {
|
|||
}
|
||||
|
||||
if (notification && !notification.is_seen) {
|
||||
dispatch(doSeeNotifications([notification.id]));
|
||||
dispatch(doLbryioNotificationsMarkSeen([notification.id]));
|
||||
}
|
||||
|
||||
const exclusiveTypes = {
|
||||
|
@ -593,7 +593,7 @@ export function doCommentCreate(
|
|||
|
||||
// send a notification
|
||||
const notification = parent_id && makeSelectNotificationForCommentId(parent_id)(state);
|
||||
if (notification && !notification.is_seen) dispatch(doSeeNotifications([notification.id]));
|
||||
if (notification && !notification.is_seen) dispatch(doLbryioNotificationsMarkSeen([notification.id]));
|
||||
|
||||
if (!signatureData) {
|
||||
return dispatch(doToast({ isError: true, message: __('Unable to verify your channel. Please try again.') }));
|
||||
|
|
|
@ -62,7 +62,7 @@ export function doLbryioNotificationList(types?: Array<string>) {
|
|||
const notificationCategories = await Lbryio.call('notification', 'categories');
|
||||
if (notificationCategories) {
|
||||
dispatch({
|
||||
type: ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED,
|
||||
type: ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED,
|
||||
data: {
|
||||
notificationCategories: notificationCategories.reverse(),
|
||||
},
|
||||
|
@ -107,7 +107,7 @@ export function doLbryioNotificationList(types?: Array<string>) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doReadNotifications(notificationsIds: Array<number>) {
|
||||
export function doLbryioNotificationsMarkRead(notificationsIds: Array<number>) {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const notifications = selectNotifications(state);
|
||||
|
@ -127,36 +127,36 @@ export function doReadNotifications(notificationsIds: Array<number>) {
|
|||
ids = Array.from(new Set([...getUnreadIds(notifications), ...getUnreadIds(notificationsFiltered)]));
|
||||
}
|
||||
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_READ_STARTED });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_STARTED });
|
||||
return Lbryio.call('notification', 'edit', { notification_ids: ids.join(','), is_read: true })
|
||||
.then(() => {
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } });
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_READ_FAILED, data: { error } });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_FAILED, data: { error } });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doSeeNotifications(notificationIds: Array<string>) {
|
||||
export function doLbryioNotificationsMarkSeen(notificationIds: Array<string>) {
|
||||
return (dispatch: Dispatch) => {
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_SEEN_STARTED });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_STARTED });
|
||||
return Lbryio.call('notification', 'edit', { notification_ids: notificationIds.join(','), is_seen: true })
|
||||
.then(() => {
|
||||
dispatch({
|
||||
type: ACTIONS.NOTIFICATION_SEEN_COMPLETED,
|
||||
type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED,
|
||||
data: {
|
||||
notificationIds,
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_SEEN_FAILED, data: { error } });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_FAILED, data: { error } });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doSeeAllNotifications() {
|
||||
export function doLbryioSeeAllNotifications() {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const notifications = selectNotifications(state);
|
||||
|
@ -169,15 +169,15 @@ export function doSeeAllNotifications() {
|
|||
const getUnseenIds = (list) => list.filter((n) => !n.is_seen).map((n) => n.id);
|
||||
const unseenIds = Array.from(new Set([...getUnseenIds(notifications), ...getUnseenIds(notificationsFiltered)]));
|
||||
|
||||
dispatch(doSeeNotifications(unseenIds));
|
||||
dispatch(doLbryioNotificationsMarkSeen(unseenIds));
|
||||
};
|
||||
}
|
||||
|
||||
export function doDeleteNotification(notificationId: number) {
|
||||
export function doLbryioDeleteNotification(notificationId: number) {
|
||||
return (dispatch: Dispatch) => {
|
||||
Lbryio.call('notification', 'delete', { notification_ids: notificationId })
|
||||
.then(() => {
|
||||
dispatch({ type: ACTIONS.NOTIFICATION_DELETE_COMPLETED, data: { notificationId } });
|
||||
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED, data: { notificationId } });
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(doToast({ isError: true, message: __('Unable to delete this right now. Please try again later.') }));
|
||||
|
|
|
@ -35,7 +35,7 @@ export default handleActions(
|
|||
},
|
||||
|
||||
// Notifications
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED]: (state) => {
|
||||
return {
|
||||
...state,
|
||||
fetchingNotifications: true,
|
||||
|
@ -57,13 +57,13 @@ export default handleActions(
|
|||
};
|
||||
}
|
||||
},
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED]: (state) => {
|
||||
return {
|
||||
...state,
|
||||
fetchingNotifications: false,
|
||||
};
|
||||
},
|
||||
[ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => {
|
||||
const { notificationCategories } = action.data;
|
||||
|
||||
return {
|
||||
|
@ -71,7 +71,7 @@ export default handleActions(
|
|||
notificationCategories,
|
||||
};
|
||||
},
|
||||
[ACTIONS.NOTIFICATION_READ_COMPLETED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED]: (state, action) => {
|
||||
const { notifications, notificationsFiltered } = state;
|
||||
const { notificationIds } = action.data;
|
||||
|
||||
|
@ -94,12 +94,12 @@ export default handleActions(
|
|||
notificationsFiltered: markIdsAsRead(notificationsFiltered, notificationIds),
|
||||
};
|
||||
},
|
||||
[ACTIONS.NOTIFICATION_READ_FAILED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_READ_FAILED]: (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
},
|
||||
[ACTIONS.NOTIFICATION_SEEN_COMPLETED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED]: (state, action) => {
|
||||
const { notifications, notificationsFiltered } = state;
|
||||
const { notificationIds } = action.data;
|
||||
|
||||
|
@ -118,7 +118,7 @@ export default handleActions(
|
|||
notificationsFiltered: markIdsAsSeen(notificationsFiltered, notificationIds),
|
||||
};
|
||||
},
|
||||
[ACTIONS.NOTIFICATION_DELETE_COMPLETED]: (state, action) => {
|
||||
[ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED]: (state, action) => {
|
||||
const { notifications, notificationsFiltered } = state;
|
||||
const { notificationId } = action.data;
|
||||
|
||||
|
|
Loading…
Reference in a new issue