more notifications renaming

This commit is contained in:
zeppi 2022-04-27 16:09:01 -04:00
parent f532aa2566
commit 43dcb39045
9 changed files with 60 additions and 51 deletions

View file

@ -1,6 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectUnseenNotificationCount } from 'redux/selectors/notifications'; 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 { selectUser } from 'redux/selectors/user';
import NotificationHeaderButton from './view'; import NotificationHeaderButton from './view';
@ -10,5 +10,5 @@ const select = (state) => ({
}); });
export default connect(select, { export default connect(select, {
doSeeAllNotifications, doLbryioSeeAllNotifications,
})(NotificationHeaderButton); })(NotificationHeaderButton);

View file

@ -14,17 +14,17 @@ import Tooltip from 'component/common/tooltip';
type Props = { type Props = {
unseenCount: number, unseenCount: number,
user: ?User, user: ?User,
doSeeAllNotifications: () => void, doLbryioSeeAllNotifications: () => void,
}; };
export default function NotificationHeaderButton(props: Props) { export default function NotificationHeaderButton(props: Props) {
const { unseenCount, user, doSeeAllNotifications } = props; const { unseenCount, user, doLbryioSeeAllNotifications } = props;
const { push } = useHistory(); const { push } = useHistory();
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui); const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
function handleMenuClick() { function handleMenuClick() {
if (unseenCount > 0) doSeeAllNotifications(); if (unseenCount > 0) doLbryioSeeAllNotifications();
push(`/$/${PAGES.NOTIFICATIONS}`); push(`/$/${PAGES.NOTIFICATIONS}`);
} }

View file

@ -1,10 +1,10 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doReadNotifications, doDeleteNotification } from 'redux/actions/notifications'; import { doLbryioNotificationsMarkRead, doLbryioDeleteNotification } from 'redux/actions/notifications';
import Notification from './view'; import Notification from './view';
const perform = (dispatch, ownProps) => ({ const perform = (dispatch, ownProps) => ({
readNotification: () => dispatch(doReadNotifications([ownProps.notification.id])), readNotification: () => dispatch(doLbryioNotificationsMarkRead([ownProps.notification.id])),
deleteNotification: () => dispatch(doDeleteNotification(ownProps.notification.id)), deleteNotification: () => dispatch(doLbryioDeleteNotification(ownProps.notification.id)),
}); });
export default connect(null, perform)(Notification); export default connect(null, perform)(Notification);

View file

@ -347,16 +347,16 @@ export const MEDIA_PAUSE = 'MEDIA_PAUSE';
export const LBRYIO_NOTIFICATION_LIST_STARTED = 'NOTIFICATION_LIST_STARTED'; export const LBRYIO_NOTIFICATION_LIST_STARTED = 'NOTIFICATION_LIST_STARTED';
export const LBRYIO_NOTIFICATION_LIST_COMPLETED = 'NOTIFICATION_LIST_COMPLETED'; export const LBRYIO_NOTIFICATION_LIST_COMPLETED = 'NOTIFICATION_LIST_COMPLETED';
export const LBRYIO_NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED'; export const LBRYIO_NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED';
export const NOTIFICATION_CATEGORIES_COMPLETED = 'NOTIFICATION_CATEGORIES_COMPLETED'; export const LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED = 'LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED';
export const NOTIFICATION_READ_STARTED = 'NOTIFICATION_READ_STARTED'; export const LBRYIO_NOTIFICATION_READ_STARTED = 'LBRYIO_NOTIFICATION_READ_STARTED';
export const NOTIFICATION_READ_COMPLETED = 'NOTIFICATION_READ_COMPLETED'; export const LBRYIO_NOTIFICATION_READ_COMPLETED = 'LBRYIO_NOTIFICATION_READ_COMPLETED';
export const NOTIFICATION_READ_FAILED = 'NOTIFICATION_READ_FAILED'; export const LBRYIO_NOTIFICATION_READ_FAILED = 'LBRYIO_NOTIFICATION_READ_FAILED';
export const NOTIFICATION_SEEN_STARTED = 'NOTIFICATION_SEEN_STARTED'; export const LBRYIO_NOTIFICATION_SEEN_STARTED = 'LBRYIO_NOTIFICATION_SEEN_STARTED';
export const NOTIFICATION_SEEN_COMPLETED = 'NOTIFICATION_SEEN_COMPLETED'; export const LBRYIO_NOTIFICATION_SEEN_COMPLETED = 'LBRYIO_NOTIFICATION_SEEN_COMPLETED';
export const NOTIFICATION_SEEN_FAILED = 'NOTIFICATION_SEEN_FAILED'; export const LBRYIO_NOTIFICATION_SEEN_FAILED = 'LBRYIO_NOTIFICATION_SEEN_FAILED';
export const NOTIFICATION_DELETE_STARTED = 'NOTIFICATION_DELETE_STARTED'; export const LBRYIO_NOTIFICATION_DELETE_STARTED = 'LBRYIO_NOTIFICATION_DELETE_STARTED';
export const NOTIFICATION_DELETE_COMPLETED = 'NOTIFICATION_DELETE_COMPLETED'; export const LBRYIO_NOTIFICATION_DELETE_COMPLETED = 'LBRYIO_NOTIFICATION_DELETE_COMPLETED';
export const NOTIFICATION_DELETE_FAILED = 'NOTIFICATION_DELETE_FAILED'; export const LBRYIO_NOTIFICATION_DELETE_FAILED = 'LBRYIO_NOTIFICATION_DELETE_FAILED';
export const CREATE_TOAST = 'CREATE_TOAST'; export const CREATE_TOAST = 'CREATE_TOAST';
export const DISMISS_TOAST = 'DISMISS_TOAST'; export const DISMISS_TOAST = 'DISMISS_TOAST';
export const CREATE_ERROR = 'CREATE_ERROR'; export const CREATE_ERROR = 'CREATE_ERROR';

View file

@ -9,7 +9,11 @@ import {
} from 'redux/selectors/notifications'; } from 'redux/selectors/notifications';
import { doCommentReactList } from 'redux/actions/comments'; import { doCommentReactList } from 'redux/actions/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app'; 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'; import NotificationsPage from './view';
const select = (state) => ({ const select = (state) => ({
@ -23,8 +27,8 @@ const select = (state) => ({
}); });
export default connect(select, { export default connect(select, {
doReadNotifications, doLbryioNotificationsMarkRead,
doLbryioNotificationList, doLbryioNotificationList,
doSeeAllNotifications, doLbryioSeeAllNotifications,
doCommentReactList, doCommentReactList,
})(NotificationsPage); })(NotificationsPage);

View file

@ -19,8 +19,8 @@ type Props = {
fetching: boolean, fetching: boolean,
unreadCount: number, unreadCount: number,
unseenCount: number, unseenCount: number,
doSeeAllNotifications: () => void, doLbryioSeeAllNotifications: () => void,
doReadNotifications: () => void, doLbryioNotificationsMarkRead: () => void,
doLbryioNotificationList: (?Array<string>) => void, doLbryioNotificationList: (?Array<string>) => void,
activeChannel: ?ChannelClaim, activeChannel: ?ChannelClaim,
doCommentReactList: (Array<string>) => Promise<any>, doCommentReactList: (Array<string>) => Promise<any>,
@ -33,8 +33,8 @@ export default function NotificationsPage(props: Props) {
fetching, fetching,
unreadCount, unreadCount,
unseenCount, unseenCount,
doSeeAllNotifications, doLbryioSeeAllNotifications,
doReadNotifications, doLbryioNotificationsMarkRead,
doLbryioNotificationList, doLbryioNotificationList,
notificationCategories, notificationCategories,
activeChannel, activeChannel,
@ -81,9 +81,9 @@ export default function NotificationsPage(props: Props) {
React.useEffect(() => { React.useEffect(() => {
if (unseenCount > 0) { if (unseenCount > 0) {
doSeeAllNotifications(); doLbryioSeeAllNotifications();
} }
}, [unseenCount, doSeeAllNotifications]); }, [unseenCount, doLbryioSeeAllNotifications]);
const stringifiedNotificationCategories = JSON.stringify(notificationCategories); const stringifiedNotificationCategories = JSON.stringify(notificationCategories);
React.useEffect(() => { React.useEffect(() => {
@ -114,7 +114,12 @@ export default function NotificationsPage(props: Props) {
{fetching && <Spinner type="small" />} {fetching && <Spinner type="small" />}
{unreadCount > 0 && ( {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 && ( {notificationCategories && (
<FormField <FormField

View file

@ -7,7 +7,7 @@ import Lbry from 'lbry';
import { parseURI, buildURI, isURIEqual } from 'util/lbryURI'; import { parseURI, buildURI, isURIEqual } from 'util/lbryURI';
import { selectClaimsByUri, selectMyChannelClaims } from 'redux/selectors/claims'; import { selectClaimsByUri, selectMyChannelClaims } from 'redux/selectors/claims';
import { doClaimSearch } from 'redux/actions/claims'; import { doClaimSearch } from 'redux/actions/claims';
import { doToast, doSeeNotifications } from 'redux/actions/notifications'; import { doToast, doLbryioNotificationsMarkSeen } from 'redux/actions/notifications';
import { import {
selectMyReactsForComment, selectMyReactsForComment,
selectOthersReactsForComment, selectOthersReactsForComment,
@ -452,7 +452,7 @@ export function doCommentReact(commentId: string, type: string) {
} }
if (notification && !notification.is_seen) { if (notification && !notification.is_seen) {
dispatch(doSeeNotifications([notification.id])); dispatch(doLbryioNotificationsMarkSeen([notification.id]));
} }
const exclusiveTypes = { const exclusiveTypes = {
@ -593,7 +593,7 @@ export function doCommentCreate(
// send a notification // send a notification
const notification = parent_id && makeSelectNotificationForCommentId(parent_id)(state); 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) { if (!signatureData) {
return dispatch(doToast({ isError: true, message: __('Unable to verify your channel. Please try again.') })); return dispatch(doToast({ isError: true, message: __('Unable to verify your channel. Please try again.') }));

View file

@ -62,7 +62,7 @@ export function doLbryioNotificationList(types?: Array<string>) {
const notificationCategories = await Lbryio.call('notification', 'categories'); const notificationCategories = await Lbryio.call('notification', 'categories');
if (notificationCategories) { if (notificationCategories) {
dispatch({ dispatch({
type: ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED, type: ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED,
data: { data: {
notificationCategories: notificationCategories.reverse(), 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) => { return (dispatch: Dispatch, getState: GetState) => {
const state = getState(); const state = getState();
const notifications = selectNotifications(state); const notifications = selectNotifications(state);
@ -127,36 +127,36 @@ export function doReadNotifications(notificationsIds: Array<number>) {
ids = Array.from(new Set([...getUnreadIds(notifications), ...getUnreadIds(notificationsFiltered)])); 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 }) return Lbryio.call('notification', 'edit', { notification_ids: ids.join(','), is_read: true })
.then(() => { .then(() => {
dispatch({ type: ACTIONS.NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } }); dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } });
}) })
.catch((error) => { .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) => { 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 }) return Lbryio.call('notification', 'edit', { notification_ids: notificationIds.join(','), is_seen: true })
.then(() => { .then(() => {
dispatch({ dispatch({
type: ACTIONS.NOTIFICATION_SEEN_COMPLETED, type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED,
data: { data: {
notificationIds, notificationIds,
}, },
}); });
}) })
.catch((error) => { .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) => { return (dispatch: Dispatch, getState: GetState) => {
const state = getState(); const state = getState();
const notifications = selectNotifications(state); 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 getUnseenIds = (list) => list.filter((n) => !n.is_seen).map((n) => n.id);
const unseenIds = Array.from(new Set([...getUnseenIds(notifications), ...getUnseenIds(notificationsFiltered)])); 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) => { return (dispatch: Dispatch) => {
Lbryio.call('notification', 'delete', { notification_ids: notificationId }) Lbryio.call('notification', 'delete', { notification_ids: notificationId })
.then(() => { .then(() => {
dispatch({ type: ACTIONS.NOTIFICATION_DELETE_COMPLETED, data: { notificationId } }); dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED, data: { notificationId } });
}) })
.catch(() => { .catch(() => {
dispatch(doToast({ isError: true, message: __('Unable to delete this right now. Please try again later.') })); dispatch(doToast({ isError: true, message: __('Unable to delete this right now. Please try again later.') }));

View file

@ -35,7 +35,7 @@ export default handleActions(
}, },
// Notifications // Notifications
[ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED]: (state) => {
return { return {
...state, ...state,
fetchingNotifications: true, fetchingNotifications: true,
@ -57,13 +57,13 @@ export default handleActions(
}; };
} }
}, },
[ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED]: (state) => {
return { return {
...state, ...state,
fetchingNotifications: false, fetchingNotifications: false,
}; };
}, },
[ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => {
const { notificationCategories } = action.data; const { notificationCategories } = action.data;
return { return {
@ -71,7 +71,7 @@ export default handleActions(
notificationCategories, notificationCategories,
}; };
}, },
[ACTIONS.NOTIFICATION_READ_COMPLETED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state; const { notifications, notificationsFiltered } = state;
const { notificationIds } = action.data; const { notificationIds } = action.data;
@ -94,12 +94,12 @@ export default handleActions(
notificationsFiltered: markIdsAsRead(notificationsFiltered, notificationIds), notificationsFiltered: markIdsAsRead(notificationsFiltered, notificationIds),
}; };
}, },
[ACTIONS.NOTIFICATION_READ_FAILED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_READ_FAILED]: (state, action) => {
return { return {
...state, ...state,
}; };
}, },
[ACTIONS.NOTIFICATION_SEEN_COMPLETED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state; const { notifications, notificationsFiltered } = state;
const { notificationIds } = action.data; const { notificationIds } = action.data;
@ -118,7 +118,7 @@ export default handleActions(
notificationsFiltered: markIdsAsSeen(notificationsFiltered, notificationIds), notificationsFiltered: markIdsAsSeen(notificationsFiltered, notificationIds),
}; };
}, },
[ACTIONS.NOTIFICATION_DELETE_COMPLETED]: (state, action) => { [ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state; const { notifications, notificationsFiltered } = state;
const { notificationId } = action.data; const { notificationId } = action.data;