mark notification seen on relevant interaction
This commit is contained in:
parent
41dfd8a0f8
commit
91d034954e
2 changed files with 26 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import * as REACTION_TYPES from 'constants/reactions';
|
import * as REACTION_TYPES from 'constants/reactions';
|
||||||
import { Lbry, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
|
import { Lbry, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
|
||||||
import {
|
import {
|
||||||
makeSelectCommentIdsForUri,
|
makeSelectCommentIdsForUri,
|
||||||
makeSelectMyReactionsForComment,
|
makeSelectMyReactionsForComment,
|
||||||
|
@ -10,6 +10,7 @@ import {
|
||||||
selectPendingCommentReacts,
|
selectPendingCommentReacts,
|
||||||
selectCommentChannel,
|
selectCommentChannel,
|
||||||
} from 'redux/selectors/comments';
|
} from 'redux/selectors/comments';
|
||||||
|
import { makeSelectNotificationForCommentId } from 'redux/selectors/notifications';
|
||||||
|
|
||||||
export function doCommentList(uri: string, page: number = 1, pageSize: number = 99999) {
|
export function doCommentList(uri: string, page: number = 1, pageSize: number = 99999) {
|
||||||
return (dispatch: Dispatch, getState: GetState) => {
|
return (dispatch: Dispatch, getState: GetState) => {
|
||||||
|
@ -104,6 +105,10 @@ export function doCommentReact(commentId: string, type: string) {
|
||||||
const channel = selectCommentChannel(state);
|
const channel = selectCommentChannel(state);
|
||||||
const pendingReacts = selectPendingCommentReacts(state);
|
const pendingReacts = selectPendingCommentReacts(state);
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
|
const notification = makeSelectNotificationForCommentId(commentId)(state);
|
||||||
|
if (notification && !notification.is_seen) {
|
||||||
|
dispatch(doSeeNotifications([notification.id]));
|
||||||
|
}
|
||||||
const exclusiveTypes = {
|
const exclusiveTypes = {
|
||||||
[REACTION_TYPES.LIKE]: REACTION_TYPES.DISLIKE,
|
[REACTION_TYPES.LIKE]: REACTION_TYPES.DISLIKE,
|
||||||
[REACTION_TYPES.DISLIKE]: REACTION_TYPES.LIKE,
|
[REACTION_TYPES.DISLIKE]: REACTION_TYPES.LIKE,
|
||||||
|
@ -205,6 +210,13 @@ export function doCommentCreate(
|
||||||
type: ACTIONS.COMMENT_CREATE_STARTED,
|
type: ACTIONS.COMMENT_CREATE_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (parent_id) {
|
||||||
|
const notification = makeSelectNotificationForCommentId(parent_id)(state);
|
||||||
|
if (notification && !notification.is_seen) {
|
||||||
|
dispatch(doSeeNotifications([notification.id]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
const namedChannelClaim = myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
const namedChannelClaim = myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
||||||
const channel_id = namedChannelClaim.claim_id;
|
const channel_id = namedChannelClaim.claim_id;
|
||||||
|
|
|
@ -4,6 +4,19 @@ export const selectState = state => state.notifications || {};
|
||||||
|
|
||||||
export const selectNotifications = createSelector(selectState, state => state.notifications);
|
export const selectNotifications = createSelector(selectState, state => state.notifications);
|
||||||
|
|
||||||
|
export const makeSelectNotificationForCommentId = id =>
|
||||||
|
createSelector(selectNotifications, notifications => {
|
||||||
|
const match =
|
||||||
|
notifications &&
|
||||||
|
notifications.find(
|
||||||
|
n =>
|
||||||
|
n.notification_parameters &&
|
||||||
|
n.notification_parameters.dynamic &&
|
||||||
|
n.notification_parameters.dynamic.hash === id
|
||||||
|
);
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
|
||||||
export const selectIsFetchingNotifications = createSelector(selectState, state => state.fetchingNotifications);
|
export const selectIsFetchingNotifications = createSelector(selectState, state => state.fetchingNotifications);
|
||||||
|
|
||||||
export const selectUnreadNotificationCount = createSelector(selectNotifications, notifications => {
|
export const selectUnreadNotificationCount = createSelector(selectNotifications, notifications => {
|
||||||
|
|
Loading…
Reference in a new issue