2019-06-27 01:59:27 +02:00
|
|
|
// @flow
|
2020-07-24 16:13:42 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2020-09-11 19:51:31 +02:00
|
|
|
import * as PAGES from 'constants/pages';
|
2021-08-31 09:05:42 +02:00
|
|
|
import * as KEYCODES from 'constants/keycodes';
|
2021-09-01 09:55:00 +02:00
|
|
|
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
import {
|
|
|
|
SORT_BY,
|
|
|
|
COMMENT_PAGE_SIZE_REPLIES,
|
|
|
|
LINKED_COMMENT_QUERY_PARAM,
|
|
|
|
THREAD_COMMENT_QUERY_PARAM,
|
|
|
|
} from 'constants/comment';
|
2020-07-24 16:13:42 +02:00
|
|
|
import { FF_MAX_CHARS_IN_COMMENT } from 'constants/form-field';
|
2020-09-30 17:59:05 +02:00
|
|
|
import { SITE_NAME, SIMPLE_SITE, ENABLE_COMMENT_REACTIONS } from 'config';
|
2020-01-30 02:02:21 +01:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { parseURI } from 'util/lbryURI';
|
2020-05-11 09:57:03 +02:00
|
|
|
import DateTime from 'component/dateTime';
|
2019-07-21 22:46:30 +02:00
|
|
|
import Button from 'component/button';
|
2020-09-11 19:51:31 +02:00
|
|
|
import Expandable from 'component/expandable';
|
2019-10-13 06:04:16 +02:00
|
|
|
import MarkdownPreview from 'component/common/markdown-preview';
|
2022-01-14 21:24:16 +01:00
|
|
|
import CommentBadge from 'component/common/comment-badge';
|
2019-10-23 09:04:40 +02:00
|
|
|
import ChannelThumbnail from 'component/channelThumbnail';
|
2021-02-11 06:12:41 +01:00
|
|
|
import { Menu, MenuButton } from '@reach/menu-button';
|
2020-01-30 02:02:21 +01:00
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
import { FormField, Form } from 'component/common/form';
|
2020-02-05 04:55:00 +01:00
|
|
|
import classnames from 'classnames';
|
2020-05-21 10:53:21 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2020-09-11 19:51:31 +02:00
|
|
|
import CommentReactions from 'component/commentReactions';
|
|
|
|
import CommentsReplies from 'component/commentsReplies';
|
|
|
|
import { useHistory } from 'react-router';
|
2020-10-07 21:14:52 +02:00
|
|
|
import CommentCreate from 'component/commentCreate';
|
2021-02-11 06:12:41 +01:00
|
|
|
import CommentMenuList from 'component/commentMenuList';
|
2021-02-16 22:09:20 +01:00
|
|
|
import UriIndicator from 'component/uriIndicator';
|
2021-04-23 21:59:48 +02:00
|
|
|
import CreditAmount from 'component/common/credit-amount';
|
2021-10-28 22:25:34 +02:00
|
|
|
import OptimizedImage from 'component/optimizedImage';
|
2021-11-09 00:05:54 +01:00
|
|
|
import { getChannelFromClaim } from 'util/claim';
|
2021-10-28 22:25:34 +02:00
|
|
|
import { parseSticker } from 'util/comments';
|
2022-02-01 21:31:39 +01:00
|
|
|
import { useIsMobile } from 'effects/use-screensize';
|
2022-03-09 19:05:37 +01:00
|
|
|
import PremiumBadge from 'component/common/premium-badge';
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
import Spinner from 'component/spinner';
|
2019-06-27 01:59:27 +02:00
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
const AUTO_EXPAND_ALL_REPLIES = false;
|
|
|
|
|
2019-06-27 01:59:27 +02:00
|
|
|
type Props = {
|
2022-02-09 16:27:11 +01:00
|
|
|
comment: Comment,
|
|
|
|
myChannelIds: ?Array<string>,
|
2021-03-02 11:12:54 +01:00
|
|
|
clearPlayingUri: () => void,
|
2020-02-05 04:55:00 +01:00
|
|
|
uri: string,
|
2021-04-02 21:14:53 +02:00
|
|
|
claim: StreamClaim,
|
2020-01-30 02:02:21 +01:00
|
|
|
channelIsBlocked: boolean, // if the channel is blacklisted in the app
|
|
|
|
claimIsMine: boolean, // if you control the claim which this comment was posted on
|
|
|
|
updateComment: (string, string) => void,
|
2021-07-15 16:43:28 +02:00
|
|
|
fetchReplies: (string, string, number, number, number) => void,
|
2021-08-04 17:01:31 +02:00
|
|
|
totalReplyPages: number,
|
2021-02-16 22:09:20 +01:00
|
|
|
commentModBlock: (string) => void,
|
2021-07-15 16:43:28 +02:00
|
|
|
linkedCommentId?: string,
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
threadCommentId?: string,
|
2021-07-15 16:43:28 +02:00
|
|
|
linkedCommentAncestors: { [string]: Array<string> },
|
2021-11-08 07:27:14 +01:00
|
|
|
hasChannels: boolean,
|
2020-09-11 19:51:31 +02:00
|
|
|
commentingEnabled: boolean,
|
|
|
|
doToast: ({ message: string }) => void,
|
|
|
|
isTopLevel?: boolean,
|
2021-10-01 14:10:27 +02:00
|
|
|
hideActions?: boolean,
|
2020-10-08 21:55:16 +02:00
|
|
|
othersReacts: ?{
|
|
|
|
like: number,
|
|
|
|
dislike: number,
|
|
|
|
},
|
2020-10-20 05:20:38 +02:00
|
|
|
commentIdentityChannel: any,
|
2021-02-09 17:05:56 +01:00
|
|
|
activeChannelClaim: ?ChannelClaim,
|
2022-03-15 17:28:55 +01:00
|
|
|
playingUri: PlayingUri,
|
2021-03-09 10:33:42 +01:00
|
|
|
stakedLevel: number,
|
2021-08-27 12:29:58 +02:00
|
|
|
supportDisabled: boolean,
|
|
|
|
setQuickReply: (any) => void,
|
|
|
|
quickReply: any,
|
2022-03-09 19:05:37 +01:00
|
|
|
selectOdyseeMembershipForUri: string,
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
fetchedReplies: Array<Comment>,
|
|
|
|
repliesFetching: boolean,
|
|
|
|
threadLevel?: number,
|
|
|
|
threadDepthLevel?: number,
|
2019-06-27 01:59:27 +02:00
|
|
|
};
|
|
|
|
|
2019-11-27 22:08:43 +01:00
|
|
|
const LENGTH_TO_COLLAPSE = 300;
|
|
|
|
|
2022-02-09 16:27:11 +01:00
|
|
|
function CommentView(props: Props) {
|
2019-10-23 09:04:40 +02:00
|
|
|
const {
|
2022-02-09 16:27:11 +01:00
|
|
|
comment,
|
|
|
|
myChannelIds,
|
2021-03-02 11:12:54 +01:00
|
|
|
clearPlayingUri,
|
2021-04-02 21:14:53 +02:00
|
|
|
claim,
|
2020-02-05 04:55:00 +01:00
|
|
|
uri,
|
2019-10-23 09:04:40 +02:00
|
|
|
channelIsBlocked,
|
2020-01-30 02:02:21 +01:00
|
|
|
updateComment,
|
2021-07-15 16:43:28 +02:00
|
|
|
fetchReplies,
|
2021-08-04 17:01:31 +02:00
|
|
|
totalReplyPages,
|
2021-07-15 16:43:28 +02:00
|
|
|
linkedCommentId,
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
threadCommentId,
|
2021-07-15 16:43:28 +02:00
|
|
|
linkedCommentAncestors,
|
2020-09-11 19:51:31 +02:00
|
|
|
commentingEnabled,
|
2021-11-08 07:27:14 +01:00
|
|
|
hasChannels,
|
2020-09-11 19:51:31 +02:00
|
|
|
doToast,
|
|
|
|
isTopLevel,
|
2021-10-01 14:10:27 +02:00
|
|
|
hideActions,
|
2020-10-08 21:55:16 +02:00
|
|
|
othersReacts,
|
2021-03-02 11:12:54 +01:00
|
|
|
playingUri,
|
2021-03-09 10:33:42 +01:00
|
|
|
stakedLevel,
|
2021-08-27 12:29:58 +02:00
|
|
|
supportDisabled,
|
|
|
|
setQuickReply,
|
|
|
|
quickReply,
|
2022-03-09 19:05:37 +01:00
|
|
|
selectOdyseeMembershipForUri,
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
fetchedReplies,
|
|
|
|
repliesFetching,
|
|
|
|
threadLevel = 0,
|
|
|
|
threadDepthLevel = 0,
|
2019-10-23 09:04:40 +02:00
|
|
|
} = props;
|
2021-07-15 16:43:28 +02:00
|
|
|
|
2022-02-09 16:27:11 +01:00
|
|
|
const {
|
|
|
|
channel_url: authorUri,
|
|
|
|
channel_name: author,
|
|
|
|
channel_id: channelId,
|
|
|
|
comment_id: commentId,
|
|
|
|
comment: message,
|
|
|
|
is_fiat: isFiat,
|
|
|
|
is_global_mod: isGlobalMod,
|
|
|
|
is_moderator: isModerator,
|
|
|
|
is_pinned: isPinned,
|
|
|
|
support_amount: supportAmount,
|
|
|
|
replies: numDirectReplies,
|
|
|
|
timestamp,
|
|
|
|
} = comment;
|
|
|
|
|
|
|
|
const timePosted = timestamp * 1000;
|
|
|
|
const commentIsMine = channelId && myChannelIds && myChannelIds.includes(channelId);
|
|
|
|
|
2022-02-01 21:31:39 +01:00
|
|
|
const isMobile = useIsMobile();
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
const ROUGH_HEADER_HEIGHT = isMobile ? 56 : 60; // @see: --header-height
|
|
|
|
|
|
|
|
const lastThreadLevel = threadDepthLevel - 1;
|
|
|
|
// Mobile: 0, 1, 2 -> new thread....., so each 3 comments
|
|
|
|
const openNewThread = threadLevel > 0 && threadLevel % lastThreadLevel === 0;
|
2022-02-01 21:31:39 +01:00
|
|
|
|
2020-09-11 19:51:31 +02:00
|
|
|
const {
|
|
|
|
push,
|
2020-10-08 17:31:36 +02:00
|
|
|
replace,
|
|
|
|
location: { pathname, search },
|
2020-09-11 19:51:31 +02:00
|
|
|
} = useHistory();
|
2021-07-15 16:43:28 +02:00
|
|
|
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
const urlParams = new URLSearchParams(search);
|
2021-10-16 07:34:06 +02:00
|
|
|
const isLinkedComment = linkedCommentId && linkedCommentId === commentId;
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
const isThreadComment = threadCommentId && threadCommentId === commentId;
|
2021-10-09 09:38:38 +02:00
|
|
|
const isInLinkedCommentChain =
|
|
|
|
linkedCommentId &&
|
|
|
|
linkedCommentAncestors[linkedCommentId] &&
|
|
|
|
linkedCommentAncestors[linkedCommentId].includes(commentId);
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
const showRepliesOnMount = isThreadComment || isInLinkedCommentChain || AUTO_EXPAND_ALL_REPLIES;
|
2021-10-09 09:38:38 +02:00
|
|
|
|
2020-09-11 19:51:31 +02:00
|
|
|
const [isReplying, setReplying] = React.useState(false);
|
2020-01-30 02:02:21 +01:00
|
|
|
const [isEditing, setEditing] = useState(false);
|
|
|
|
const [editedMessage, setCommentValue] = useState(message);
|
|
|
|
const [charCount, setCharCount] = useState(editedMessage.length);
|
2021-10-09 09:38:38 +02:00
|
|
|
const [showReplies, setShowReplies] = useState(showRepliesOnMount);
|
|
|
|
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
|
2020-08-24 19:35:21 +02:00
|
|
|
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
|
2020-10-08 21:55:16 +02:00
|
|
|
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
|
|
|
|
const likesCount = (othersReacts && othersReacts.like) || 0;
|
|
|
|
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
|
|
|
|
const totalLikesAndDislikes = likesCount + dislikesCount;
|
2020-10-26 19:06:33 +01:00
|
|
|
const slimedToDeath = totalLikesAndDislikes >= 5 && dislikesCount / totalLikesAndDislikes > 0.8;
|
2021-11-09 00:05:54 +01:00
|
|
|
const contentChannelClaim = getChannelFromClaim(claim);
|
|
|
|
const commentByOwnerOfContent = contentChannelClaim && contentChannelClaim.permanent_url === authorUri;
|
2021-10-28 22:25:34 +02:00
|
|
|
const stickerFromMessage = parseSticker(message);
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
const isExpandable = editedMessage.length >= LENGTH_TO_COLLAPSE;
|
2021-02-09 17:05:56 +01:00
|
|
|
|
2020-10-08 17:31:36 +02:00
|
|
|
let channelOwnerOfContent;
|
|
|
|
try {
|
|
|
|
const { channelName } = parseURI(uri);
|
|
|
|
if (channelName) {
|
|
|
|
channelOwnerOfContent = channelName;
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
2019-12-04 19:07:40 +01:00
|
|
|
|
2019-10-23 09:04:40 +02:00
|
|
|
useEffect(() => {
|
2020-01-30 02:02:21 +01:00
|
|
|
if (isEditing) {
|
|
|
|
setCharCount(editedMessage.length);
|
|
|
|
|
|
|
|
// a user will try and press the escape key to cancel editing their comment
|
2021-02-16 22:09:20 +01:00
|
|
|
const handleEscape = (event) => {
|
2021-08-31 09:05:42 +02:00
|
|
|
if (event.keyCode === KEYCODES.ESCAPE) {
|
2020-01-30 02:02:21 +01:00
|
|
|
setEditing(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleEscape);
|
|
|
|
|
|
|
|
// removes the listener so it doesn't cause problems elsewhere in the app
|
|
|
|
return () => {
|
|
|
|
window.removeEventListener('keydown', handleEscape);
|
|
|
|
};
|
|
|
|
}
|
2021-02-09 17:05:56 +01:00
|
|
|
}, [author, authorUri, editedMessage, isEditing, setEditing]);
|
2020-01-30 02:02:21 +01:00
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (page > 0) {
|
|
|
|
fetchReplies(uri, commentId, page, COMMENT_PAGE_SIZE_REPLIES, SORT_BY.OLDEST);
|
|
|
|
}
|
|
|
|
}, [page, uri, commentId, fetchReplies]);
|
|
|
|
|
2020-01-30 02:02:21 +01:00
|
|
|
function handleEditMessageChanged(event) {
|
2020-07-24 16:13:42 +02:00
|
|
|
setCommentValue(!SIMPLE_SITE && advancedEditor ? event : event.target.value);
|
2020-01-30 02:02:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-26 20:50:44 +01:00
|
|
|
function handleEditComment() {
|
2022-03-15 17:28:55 +01:00
|
|
|
if (playingUri.source === 'comment') {
|
2021-03-02 11:12:54 +01:00
|
|
|
clearPlayingUri();
|
|
|
|
}
|
2021-01-26 20:50:44 +01:00
|
|
|
setEditing(true);
|
|
|
|
}
|
|
|
|
|
2020-01-30 02:02:21 +01:00
|
|
|
function handleSubmit() {
|
|
|
|
updateComment(commentId, editedMessage);
|
2021-08-27 12:29:58 +02:00
|
|
|
if (setQuickReply) setQuickReply({ ...quickReply, comment_id: commentId, comment: editedMessage });
|
2020-01-30 02:02:21 +01:00
|
|
|
setEditing(false);
|
|
|
|
}
|
|
|
|
|
2020-09-11 19:51:31 +02:00
|
|
|
function handleCommentReply() {
|
|
|
|
if (!hasChannels) {
|
|
|
|
push(`/$/${PAGES.CHANNEL_NEW}?redirect=${pathname}`);
|
|
|
|
doToast({ message: __('A channel is required to comment on %SITE_NAME%', { SITE_NAME }) });
|
|
|
|
} else {
|
2020-10-07 21:14:52 +02:00
|
|
|
setReplying(!isReplying);
|
2020-09-11 19:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 17:31:36 +02:00
|
|
|
function handleTimeClick() {
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
urlParams.set(LINKED_COMMENT_QUERY_PARAM, commentId);
|
2020-10-08 17:31:36 +02:00
|
|
|
replace(`${pathname}?${urlParams.toString()}`);
|
|
|
|
}
|
|
|
|
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
function handleOpenNewThread() {
|
|
|
|
urlParams.set(LINKED_COMMENT_QUERY_PARAM, commentId);
|
|
|
|
urlParams.set(THREAD_COMMENT_QUERY_PARAM, commentId);
|
|
|
|
push({ pathname, search: urlParams.toString() });
|
|
|
|
}
|
|
|
|
|
2022-02-04 21:59:11 +01:00
|
|
|
const linkedCommentRef = React.useCallback(
|
|
|
|
(node) => {
|
|
|
|
if (node !== null && window.pendingLinkedCommentScroll) {
|
|
|
|
delete window.pendingLinkedCommentScroll;
|
|
|
|
|
2022-02-04 22:39:48 +01:00
|
|
|
const mobileChatElem = document.querySelector('.MuiPaper-root .card--enable-overflow');
|
|
|
|
const elem = (isMobile && mobileChatElem) || window;
|
2022-02-04 21:59:11 +01:00
|
|
|
|
|
|
|
if (elem) {
|
|
|
|
// $FlowFixMe
|
|
|
|
elem.scrollTo({
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
// $FlowFixMe
|
|
|
|
top: node.getBoundingClientRect().top + (mobileChatElem ? 0 : elem.scrollY) - ROUGH_HEADER_HEIGHT,
|
2022-02-04 21:59:11 +01:00
|
|
|
left: 0,
|
|
|
|
behavior: 'smooth',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
[ROUGH_HEADER_HEIGHT, isMobile]
|
2022-02-04 21:59:11 +01:00
|
|
|
);
|
2021-10-16 07:34:06 +02:00
|
|
|
|
2019-06-27 01:59:27 +02:00
|
|
|
return (
|
2020-02-05 04:55:00 +01:00
|
|
|
<li
|
2020-08-24 19:35:21 +02:00
|
|
|
className={classnames('comment', {
|
2020-10-07 21:14:52 +02:00
|
|
|
'comment--top-level': isTopLevel,
|
2020-09-11 19:51:31 +02:00
|
|
|
'comment--reply': !isTopLevel,
|
2021-04-23 21:59:48 +02:00
|
|
|
'comment--superchat': supportAmount > 0,
|
2020-08-24 19:35:21 +02:00
|
|
|
})}
|
|
|
|
id={commentId}
|
2020-02-05 04:55:00 +01:00
|
|
|
>
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
<div className="comment__thumbnail-wrapper">
|
|
|
|
{authorUri ? (
|
|
|
|
<ChannelThumbnail
|
|
|
|
uri={authorUri}
|
|
|
|
obscure={channelIsBlocked}
|
|
|
|
xsmall
|
|
|
|
className="comment__author-thumbnail"
|
|
|
|
checkMembership={false}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<ChannelThumbnail xsmall className="comment__author-thumbnail" checkMembership={false} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{numDirectReplies > 0 && showReplies && (
|
|
|
|
<Button className="comment__threadline" aria-label="Hide Replies" onClick={() => setShowReplies(false)} />
|
|
|
|
)}
|
|
|
|
</div>
|
2019-10-24 19:24:53 +02:00
|
|
|
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
<div className="comment__content" ref={isLinkedComment || isThreadComment ? linkedCommentRef : undefined}>
|
|
|
|
<div
|
|
|
|
className={classnames('comment__body-container', {
|
|
|
|
[COMMENT_HIGHLIGHTED]: isLinkedComment || (isThreadComment && !linkedCommentId),
|
|
|
|
'comment--slimed': slimedToDeath && !displayDeadComment,
|
|
|
|
})}
|
|
|
|
>
|
2020-09-11 19:51:31 +02:00
|
|
|
<div className="comment__meta">
|
|
|
|
<div className="comment__meta-information">
|
|
|
|
{!author ? (
|
|
|
|
<span className="comment__author">{__('Anonymous')}</span>
|
|
|
|
) : (
|
2021-04-02 21:14:53 +02:00
|
|
|
<UriIndicator
|
|
|
|
className={classnames('comment__author', {
|
|
|
|
'comment__author--creator': commentByOwnerOfContent,
|
|
|
|
})}
|
|
|
|
link
|
|
|
|
uri={authorUri}
|
2022-03-09 19:05:37 +01:00
|
|
|
comment
|
2022-02-26 19:47:54 +01:00
|
|
|
showAtSign
|
2021-04-02 21:14:53 +02:00
|
|
|
/>
|
2021-03-24 03:53:33 +01:00
|
|
|
)}
|
2022-03-09 19:05:37 +01:00
|
|
|
{isGlobalMod && <CommentBadge label={__('Admin')} icon={ICONS.BADGE_ADMIN} />}
|
|
|
|
{isModerator && <CommentBadge label={__('Moderator')} icon={ICONS.BADGE_MOD} />}
|
|
|
|
<PremiumBadge membership={selectOdyseeMembershipForUri} linkPage />
|
2021-04-23 21:59:48 +02:00
|
|
|
<Button
|
|
|
|
className="comment__time"
|
|
|
|
onClick={handleTimeClick}
|
|
|
|
label={<DateTime date={timePosted} timeAgo />}
|
|
|
|
/>
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
{supportAmount > 0 && <CreditAmount isFiat={isFiat} amount={supportAmount} superChatLight size={12} />}
|
2020-10-08 17:31:36 +02:00
|
|
|
|
|
|
|
{isPinned && (
|
|
|
|
<span className="comment__pin">
|
2020-10-20 05:20:38 +02:00
|
|
|
<Icon icon={ICONS.PIN} size={14} />
|
2020-10-08 17:31:36 +02:00
|
|
|
{channelOwnerOfContent
|
|
|
|
? __('Pinned by @%channel%', { channel: channelOwnerOfContent })
|
|
|
|
: __('Pinned by creator')}
|
|
|
|
</span>
|
|
|
|
)}
|
2020-09-11 19:51:31 +02:00
|
|
|
</div>
|
|
|
|
<div className="comment__menu">
|
|
|
|
<Menu>
|
2021-03-03 19:50:16 +01:00
|
|
|
<MenuButton className="menu__button">
|
2021-09-01 07:58:48 +02:00
|
|
|
<Icon size={18} icon={ICONS.MORE_VERTICAL} />
|
2020-09-11 19:51:31 +02:00
|
|
|
</MenuButton>
|
2021-02-11 06:12:41 +01:00
|
|
|
<CommentMenuList
|
|
|
|
uri={uri}
|
|
|
|
isTopLevel={isTopLevel}
|
|
|
|
isPinned={isPinned}
|
|
|
|
commentId={commentId}
|
|
|
|
authorUri={authorUri}
|
|
|
|
commentIsMine={commentIsMine}
|
|
|
|
handleEditComment={handleEditComment}
|
2021-07-19 23:22:39 +02:00
|
|
|
supportAmount={supportAmount}
|
2021-08-27 12:29:58 +02:00
|
|
|
setQuickReply={setQuickReply}
|
2021-02-11 06:12:41 +01:00
|
|
|
/>
|
2020-09-11 19:51:31 +02:00
|
|
|
</Menu>
|
|
|
|
</div>
|
2020-01-30 02:02:21 +01:00
|
|
|
</div>
|
2020-09-11 19:51:31 +02:00
|
|
|
<div>
|
|
|
|
{isEditing ? (
|
|
|
|
<Form onSubmit={handleSubmit}>
|
|
|
|
<FormField
|
2021-04-23 21:59:48 +02:00
|
|
|
className="comment__edit-input"
|
2020-09-11 19:51:31 +02:00
|
|
|
type={!SIMPLE_SITE && advancedEditor ? 'markdown' : 'textarea'}
|
|
|
|
name="editing_comment"
|
|
|
|
value={editedMessage}
|
|
|
|
charCount={charCount}
|
|
|
|
onChange={handleEditMessageChanged}
|
|
|
|
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
|
2022-02-04 21:59:11 +01:00
|
|
|
handleSubmit={handleSubmit}
|
2020-01-30 02:02:21 +01:00
|
|
|
/>
|
2021-04-23 21:59:48 +02:00
|
|
|
<div className="section__actions section__actions--no-margin">
|
2020-09-11 19:51:31 +02:00
|
|
|
<Button
|
|
|
|
button="primary"
|
|
|
|
type="submit"
|
|
|
|
label={__('Done')}
|
|
|
|
requiresAuth={IS_WEB}
|
|
|
|
disabled={message === editedMessage}
|
|
|
|
/>
|
|
|
|
<Button button="link" label={__('Cancel')} onClick={() => setEditing(false)} />
|
|
|
|
</div>
|
|
|
|
</Form>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<div className="comment__message">
|
2020-10-08 21:55:16 +02:00
|
|
|
{slimedToDeath && !displayDeadComment ? (
|
|
|
|
<div onClick={() => setDisplayDeadComment(true)} className="comment__dead">
|
2020-10-09 17:38:50 +02:00
|
|
|
{__('This comment was slimed to death.')} <Icon icon={ICONS.SLIME_ACTIVE} />
|
2020-10-08 21:55:16 +02:00
|
|
|
</div>
|
2021-10-28 22:25:34 +02:00
|
|
|
) : stickerFromMessage ? (
|
|
|
|
<div className="sticker__comment">
|
2021-11-05 20:31:51 +01:00
|
|
|
<OptimizedImage src={stickerFromMessage.url} waitLoad loading="lazy" />
|
2021-10-28 22:25:34 +02:00
|
|
|
</div>
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
) : isExpandable ? (
|
|
|
|
<Expandable beginCollapsed>
|
2021-03-09 10:33:42 +01:00
|
|
|
<MarkdownPreview
|
|
|
|
content={message}
|
|
|
|
promptLinks
|
|
|
|
parentCommentId={commentId}
|
|
|
|
stakedLevel={stakedLevel}
|
2022-03-09 19:05:37 +01:00
|
|
|
hasMembership={selectOdyseeMembershipForUri}
|
2021-03-09 10:33:42 +01:00
|
|
|
/>
|
2020-09-11 19:51:31 +02:00
|
|
|
</Expandable>
|
|
|
|
) : (
|
2021-03-09 10:33:42 +01:00
|
|
|
<MarkdownPreview
|
|
|
|
content={message}
|
|
|
|
promptLinks
|
|
|
|
parentCommentId={commentId}
|
|
|
|
stakedLevel={stakedLevel}
|
2022-03-09 19:05:37 +01:00
|
|
|
hasMembership={selectOdyseeMembershipForUri}
|
2021-03-09 10:33:42 +01:00
|
|
|
/>
|
2020-09-11 19:51:31 +02:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
|
2021-10-01 14:10:27 +02:00
|
|
|
{!hideActions && (
|
2021-07-15 16:43:28 +02:00
|
|
|
<div className="comment__actions">
|
|
|
|
<Button
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
requiresAuth={IS_WEB}
|
|
|
|
label={commentingEnabled ? __('Reply') : __('Log in to reply')}
|
|
|
|
className="comment__action"
|
|
|
|
onClick={handleCommentReply}
|
|
|
|
icon={ICONS.REPLY}
|
|
|
|
iconSize={isMobile && 12}
|
2021-07-15 16:43:28 +02:00
|
|
|
/>
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
{ENABLE_COMMENT_REACTIONS && <CommentReactions uri={uri} commentId={commentId} />}
|
2021-07-15 16:43:28 +02:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
{repliesFetching && (!fetchedReplies || fetchedReplies.length === 0) ? (
|
|
|
|
<span className="comment__actions comment__replies-loading">
|
|
|
|
<Spinner text={numDirectReplies > 1 ? __('Loading Replies') : __('Loading Reply')} type="small" />
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
numDirectReplies > 0 && (
|
|
|
|
<div className="comment__actions">
|
|
|
|
{!showReplies ? (
|
|
|
|
openNewThread ? (
|
|
|
|
<Button
|
|
|
|
label={__('Continue Thread')}
|
|
|
|
button="link"
|
|
|
|
onClick={handleOpenNewThread}
|
|
|
|
iconRight={ICONS.ARROW_RIGHT}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
label={
|
|
|
|
numDirectReplies < 2
|
|
|
|
? __('Show reply')
|
|
|
|
: __('Show %count% replies', { count: numDirectReplies })
|
|
|
|
}
|
|
|
|
button="link"
|
|
|
|
onClick={() => {
|
|
|
|
setShowReplies(true);
|
|
|
|
if (page === 0) {
|
|
|
|
setPage(1);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
iconRight={ICONS.DOWN}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
label={__('Hide replies')}
|
|
|
|
button="link"
|
|
|
|
onClick={() => setShowReplies(false)}
|
|
|
|
iconRight={ICONS.UP}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)
|
2021-07-15 16:43:28 +02:00
|
|
|
)}
|
|
|
|
|
2020-10-07 21:14:52 +02:00
|
|
|
{isReplying && (
|
|
|
|
<CommentCreate
|
|
|
|
isReply
|
|
|
|
uri={uri}
|
|
|
|
parentId={commentId}
|
2021-07-15 16:43:28 +02:00
|
|
|
onDoneReplying={() => {
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
if (openNewThread) {
|
|
|
|
handleOpenNewThread();
|
|
|
|
} else {
|
|
|
|
setShowReplies(true);
|
|
|
|
}
|
2021-07-15 16:43:28 +02:00
|
|
|
setReplying(false);
|
|
|
|
}}
|
|
|
|
onCancelReplying={() => {
|
|
|
|
setReplying(false);
|
|
|
|
}}
|
2021-08-27 12:29:58 +02:00
|
|
|
supportDisabled={supportDisabled}
|
2020-10-07 21:14:52 +02:00
|
|
|
/>
|
|
|
|
)}
|
2020-09-11 19:51:31 +02:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
2019-10-24 19:24:53 +02:00
|
|
|
</div>
|
2020-09-11 19:51:31 +02:00
|
|
|
|
Re-design comment threads (#1489)
* Redesign threadline and fetching state
- threadline goes right below channel avatar, mimicking reddits implementation, has a increase effect on hover and is slimmer, creating more space for comments on screen
- fetching state now replaces show/hide button, also mimicking reddit, and now says that it is loading, instead of a blank spinner, and also improves space a bit
* Redesign comment threads
- Allow for infinite comment chains
- Can go back and forth between the pages
- Can go back to all comments or to the first comment in the chain
- Some other improvements, which include:
- add title on non-drawer comment sections (couldn't see amount of comments)
- fix Expandable component (would begin expanded and collapse after the effect runs, which looked bad and shifted the layout, now each comments greater than the set length begins collapsed)
- used constants for consistency
* Fix replying to last thread comment
* Fix buttons condition (only on fetched comment to avoid deleted case)
* Fix auto-scroll
* Bring back instant feedback for Show More replies
* Improve thread back links
- Now going back to all comments links the top-level comment for easier navigation
- Going back to ~ previous ~ now goes back into the chain instead of topmost level
* Clear timeouts due to unrelated issue
* Fix deep thread linked comment case and more scroll improvements
* More minor changes
* Flow
* Fix commentList tile style
* Fix long channel names overflowing on small screens
* More scroll changes
* Fix threadline
* Revert "Fix long channel names overflowing on small screens"
This reverts commit e4d2dc7da5861ed8136a60f3352e41a690cd4d33.
* Fix replies fetch
* Revert "Fix replies fetch"
This reverts commit ec70054675a604a7a5f3764ba07c36bf7b0f49c8.
* Cleanup and make smooth
* Always use linked comment on threads
* Cleanup
* Higlight thread comment
* Fix comment body styles
2022-05-16 12:22:13 +02:00
|
|
|
{showReplies && (
|
|
|
|
<CommentsReplies
|
|
|
|
threadLevel={threadLevel}
|
|
|
|
uri={uri}
|
|
|
|
parentId={commentId}
|
|
|
|
linkedCommentId={linkedCommentId}
|
|
|
|
threadCommentId={threadCommentId}
|
|
|
|
numDirectReplies={numDirectReplies}
|
|
|
|
onShowMore={() => setPage(page + 1)}
|
|
|
|
hasMore={page < totalReplyPages}
|
|
|
|
threadDepthLevel={threadDepthLevel}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2019-06-27 01:59:27 +02:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:27:11 +01:00
|
|
|
export default CommentView;
|