Fix notifications fetching issues #7002
3 changed files with 15 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import Comment from './view';
|
import Comment from './view';
|
||||||
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
|
import { makeSelectClaimIsMine, makeSelectClaimForUri, doResolveUri } from 'lbry-redux';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
|
import { makeSelectMyReactionsForComment, makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
|
||||||
import { doCommentReact } from 'redux/actions/comments';
|
import { doCommentReact } from 'redux/actions/comments';
|
||||||
|
@ -21,6 +21,7 @@ const select = (state, props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
|
resolve: (uri) => dispatch(doResolveUri(uri)),
|
||||||
react: (commentId, type) => dispatch(doCommentReact(commentId, type)),
|
react: (commentId, type) => dispatch(doCommentReact(commentId, type)),
|
||||||
doToast: (params) => dispatch(doToast(params)),
|
doToast: (params) => dispatch(doToast(params)),
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,9 +17,11 @@ type Props = {
|
||||||
pendingCommentReacts: Array<string>,
|
pendingCommentReacts: Array<string>,
|
||||||
claimIsMine: boolean,
|
claimIsMine: boolean,
|
||||||
activeChannelId: ?string,
|
activeChannelId: ?string,
|
||||||
|
uri: string,
|
||||||
claim: ?ChannelClaim,
|
claim: ?ChannelClaim,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
hideCreatorLike: boolean,
|
hideCreatorLike: boolean,
|
||||||
|
resolve: (string) => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CommentReactions(props: Props) {
|
export default function CommentReactions(props: Props) {
|
||||||
|
@ -29,15 +31,24 @@ export default function CommentReactions(props: Props) {
|
||||||
commentId,
|
commentId,
|
||||||
react,
|
react,
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
|
uri,
|
||||||
claim,
|
claim,
|
||||||
activeChannelId,
|
activeChannelId,
|
||||||
doToast,
|
doToast,
|
||||||
hideCreatorLike,
|
hideCreatorLike,
|
||||||
|
resolve,
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
push,
|
push,
|
||||||
location: { pathname },
|
location: { pathname },
|
||||||
} = useHistory();
|
} = useHistory();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!claim) {
|
||||||
|
resolve(uri);
|
||||||
|
}
|
||||||
|
}, [claim, resolve, uri]);
|
||||||
|
|
||||||
const canCreatorReact =
|
const canCreatorReact =
|
||||||
claim &&
|
claim &&
|
||||||
claimIsMine &&
|
claimIsMine &&
|
||||||
|
|
|
@ -47,7 +47,7 @@ export default function NotificationsPage(props: Props) {
|
||||||
|
|
||||||
// Fetch reacts
|
// Fetch reacts
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (initialFetchDone && activeChannel) {
|
if ((!fetching || initialFetchDone) && activeChannel) {
|
||||||
let idsForReactionFetch = [];
|
let idsForReactionFetch = [];
|
||||||
list.map((notification) => {
|
list.map((notification) => {
|
||||||
const { notification_rule, notification_parameters } = notification;
|
const { notification_rule, notification_parameters } = notification;
|
||||||
|
@ -70,7 +70,7 @@ export default function NotificationsPage(props: Props) {
|
||||||
doCommentReactList(idsForReactionFetch);
|
doCommentReactList(idsForReactionFetch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [initialFetchDone, doCommentReactList, list, activeChannel]);
|
}, [doCommentReactList, list, activeChannel, fetching, initialFetchDone]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (unseenCount > 0 || unreadCount > 0) {
|
if (unseenCount > 0 || unreadCount > 0) {
|
||||||
|
|
Loading…
Reference in a new issue