Handle removed livestream comments

This commit is contained in:
infinite-persistence 2021-12-30 11:43:53 +08:00 committed by Thomas Zarebczan
parent 12eeb06c40
commit 0ccf9f2c05
5 changed files with 27 additions and 1 deletions

View file

@ -18,6 +18,7 @@ declare type Comment = {
is_creator: boolean, is_creator: boolean,
is_global_mod: boolean, is_global_mod: boolean,
is_fiat?: boolean, is_fiat?: boolean,
removed?: boolean,
}; };
declare type PerChannelSettings = { declare type PerChannelSettings = {

View file

@ -2,6 +2,7 @@
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
import React from 'react'; import React from 'react';
import { parseURI } from 'util/lbryURI'; import { parseURI } from 'util/lbryURI';
import Empty from 'component/common/empty';
import MarkdownPreview from 'component/common/markdown-preview'; import MarkdownPreview from 'component/common/markdown-preview';
import Tooltip from 'component/common/tooltip'; import Tooltip from 'component/common/tooltip';
import ChannelThumbnail from 'component/channelThumbnail'; import ChannelThumbnail from 'component/channelThumbnail';
@ -107,7 +108,11 @@ function LivestreamComment(props: Props) {
</span> </span>
)} )}
{stickerFromMessage ? ( {comment.removed ? (
<div className="livestream-comment__text">
<Empty text={__('[Removed]')} />
</div>
) : stickerFromMessage ? (
<div className="sticker__comment"> <div className="sticker__comment">
<OptimizedImage src={stickerFromMessage.url} waitLoad loading="lazy" /> <OptimizedImage src={stickerFromMessage.url} waitLoad loading="lazy" />
</div> </div>

View file

@ -392,6 +392,7 @@ export const COMMENT_REACT_FAILED = 'COMMENT_REACT_FAILED';
export const COMMENT_PIN_STARTED = 'COMMENT_PIN_STARTED'; export const COMMENT_PIN_STARTED = 'COMMENT_PIN_STARTED';
export const COMMENT_PIN_COMPLETED = 'COMMENT_PIN_COMPLETED'; export const COMMENT_PIN_COMPLETED = 'COMMENT_PIN_COMPLETED';
export const COMMENT_PIN_FAILED = 'COMMENT_PIN_FAILED'; export const COMMENT_PIN_FAILED = 'COMMENT_PIN_FAILED';
export const COMMENT_MARK_AS_REMOVED = 'COMMENT_MARK_AS_REMOVED';
export const COMMENT_MODERATION_BLOCK_LIST_STARTED = 'COMMENT_MODERATION_BLOCK_LIST_STARTED'; export const COMMENT_MODERATION_BLOCK_LIST_STARTED = 'COMMENT_MODERATION_BLOCK_LIST_STARTED';
export const COMMENT_MODERATION_BLOCK_LIST_COMPLETED = 'COMMENT_MODERATION_BLOCK_LIST_COMPLETED'; export const COMMENT_MODERATION_BLOCK_LIST_COMPLETED = 'COMMENT_MODERATION_BLOCK_LIST_COMPLETED';
export const COMMENT_MODERATION_BLOCK_LIST_FAILED = 'COMMENT_MODERATION_BLOCK_LIST_FAILED'; export const COMMENT_MODERATION_BLOCK_LIST_FAILED = 'COMMENT_MODERATION_BLOCK_LIST_FAILED';

View file

@ -121,6 +121,13 @@ export const doCommentSocketConnect = (uri, claimId) => (dispatch) => {
}, },
}); });
} }
if (response.type === 'removed') {
const { comment_id } = response.data.comment;
dispatch({
type: ACTIONS.COMMENT_MARK_AS_REMOVED,
data: { comment_id },
});
}
}); });
}; };

View file

@ -697,6 +697,18 @@ export default handleActions(
}; };
}, },
[ACTIONS.COMMENT_MARK_AS_REMOVED]: (state: CommentsState, action: any) => {
const { comment_id } = action.data;
const commentById = Object.assign({}, state.commentById);
if (!commentById[comment_id]) {
return state;
}
commentById[comment_id] = { ...commentById[comment_id], removed: true };
return { ...state, commentById };
},
[ACTIONS.COMMENT_MODERATION_BLOCK_LIST_STARTED]: (state: CommentsState, action: any) => ({ [ACTIONS.COMMENT_MODERATION_BLOCK_LIST_STARTED]: (state: CommentsState, action: any) => ({
...state, ...state,
fetchingModerationBlockList: true, fetchingModerationBlockList: true,