lbry-desktop/flow-typed/Comment.js

333 lines
11 KiB
JavaScript
Raw Normal View History

2020-08-24 19:35:21 +02:00
declare type Comment = {
comment: string, // comment body
comment_id: string, // sha256 digest
claim_id: string, // id linking to the claim this comment
timestamp: number, // integer representing unix-time
is_hidden: boolean, // claim owner may enable/disable this
channel_id: string, // claimId of channel signing this comment
channel_name?: string, // name of channel claim
2020-08-24 19:35:21 +02:00
channel_url?: string, // full lbry url to signing channel
signature?: string, // signature of comment by originating channel
signing_ts?: string, // timestamp used when signing this comment
is_channel_signature_valid?: boolean, // whether or not the signature could be validated
parent_id?: number, // comment_id of comment this is in reply to
is_pinned: boolean,
2021-04-23 21:59:48 +02:00
support_amount: number,
replies: number, // number of direct replies (i.e. excluding nested replies).
is_moderator: boolean,
is_creator: boolean,
is_global_mod: boolean,
2021-07-17 18:08:53 +02:00
is_fiat?: boolean,
2021-12-30 04:43:53 +01:00
removed?: boolean,
2020-08-24 19:35:21 +02:00
};
2022-02-07 19:03:10 +01:00
declare type CommentSubmitParams = {
comment: string,
claim_id: string,
parent_id?: string,
txid?: ?string,
payment_intent_id?: ?string,
environment?: ?string,
sticker: boolean,
};
2021-04-20 10:40:53 +02:00
declare type PerChannelSettings = {
words?: Array<string>,
comments_enabled?: boolean,
min_tip_amount_comment?: number,
min_tip_amount_super_chat?: number,
slow_mode_min_gap?: number,
2022-02-23 07:29:14 +01:00
time_since_first_comment?: number,
2021-04-20 10:40:53 +02:00
};
2020-08-24 19:35:21 +02:00
// todo: relate individual comments to their commentId
declare type CommentsState = {
commentsByUri: { [string]: string }, // URI -> claimId (TODO: remove)
2021-04-23 21:59:48 +02:00
superChatsByUri: { [string]: { totalAmount: number, comments: Array<Comment> } },
byId: { [string]: Array<string> }, // ClaimID -> list of fetched comment IDs.
totalCommentsById: {}, // ClaimId -> ultimate total (including replies) in commentron.
repliesByParentId: { [string]: Array<string> }, // ParentCommentID -> list of fetched replies.
repliesTotalPagesByParentId: {}, // ParentCommentID -> total number of reply pages for a parentId in commentron.
topLevelCommentsById: { [string]: Array<string> }, // ClaimID -> list of fetched top level comments.
topLevelTotalPagesById: { [string]: number }, // ClaimID -> total number of top-level pages in commentron. Based on COMMENT_PAGE_SIZE_TOP_LEVEL.
topLevelTotalCommentsById: { [string]: number }, // ClaimID -> total top level comments in commentron.
commentById: { [string]: Comment }, // commentId -> Comment
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
fetchedCommentAncestors: { [string]: Array<string> }, // {"fetchedCommentId": ["parentId", "grandParentId", ...]}
2021-08-09 08:26:03 +02:00
pinnedCommentsById: {}, // ClaimId -> array of pinned comment IDs
2020-08-24 19:35:21 +02:00
isLoading: boolean,
isLoadingById: boolean,
isLoadingByParentId: { [string]: boolean },
isCommenting: boolean,
2020-08-24 19:35:21 +02:00
myComments: ?Set<string>,
2020-09-29 16:10:23 +02:00
isFetchingReacts: boolean,
myReactsByCommentId: ?{ [string]: Array<string> }, // {"CommentId:MyChannelId": ["like", "dislike", ...]}
othersReactsByCommentId: ?{ [string]: { [string]: number } }, // {"CommentId:MyChannelId": {"like": 2, "dislike": 2, ...}}
pendingCommentReactions: Array<string>,
2021-05-25 08:17:36 +02:00
moderationBlockList: ?Array<string>, // @KP rename to "personalBlockList"?
adminBlockList: ?Array<string>,
moderatorBlockList: ?Array<string>,
2022-02-07 19:03:10 +01:00
moderatorBlockListDelegatorsMap: { [string]: Array<string> }, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
fetchingModerationBlockList: boolean,
2021-05-25 08:17:36 +02:00
moderationDelegatesById: { [string]: Array<{ channelId: string, channelName: string }> },
fetchingModerationDelegates: boolean,
2022-02-07 19:03:10 +01:00
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
2021-05-25 08:17:36 +02:00
fetchingModerationDelegators: boolean,
blockingByUri: {},
unBlockingByUri: {},
personalTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
adminTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
moderatorTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
2022-02-07 19:03:10 +01:00
togglingForDelegatorMap: { [string]: Array<string> }, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
2021-04-20 10:40:53 +02:00
settingsByChannelId: { [string]: PerChannelSettings }, // ChannelID -> settings
fetchingSettings: boolean,
fetchingBlockedWords: boolean,
myCommentedChannelIdsById: { [string]: Array<string> }, // [content-claim-id] -> array of own channels IDs that have commented before.
2020-08-24 19:35:21 +02:00
};
2020-09-29 16:10:23 +02:00
// Authorization parameters for calls requiring user authentication
declare type Authorization = {
channel_name: string,
channel_id: string,
signature: string,
signing_ts: string,
};
// ModAuthorization parameters for calls requiring creator/moderator authentication
declare type ModAuthorization = {
// Publisher, Moderator or Commentron Admin
mod_channel_id: string,
mod_channel_name: string,
// Creator that Moderator is delegated from. Used for delegated moderation
creator_channel_id: string,
creator_channel_name: string,
signature: string,
signing_ts: string,
};
2020-09-29 16:10:23 +02:00
declare type CommentReactParams = {
comment_ids: string,
channel_name: string,
channel_id: string,
react_type: string,
clear_types?: string,
remove?: boolean,
};
2021-04-23 21:59:48 +02:00
declare type ReactionReactParams = {
comment_ids: string,
signature?: string,
signing_ts?: string,
remove?: boolean,
clear_types?: string,
type: string,
channel_id: string,
channel_name: string,
};
declare type ReactionReactResponse = {
2022-02-07 19:03:10 +01:00
Reactions: { [string]: { [string]: number } },
};
declare type ReactionListParams = {
comment_ids: string, // CSV of IDs
channel_id?: string,
channel_name?: string,
signature?: string,
signing_ts?: string,
types?: string,
};
declare type ReactionListResponse = {
my_reactions: Array<MyReactions>,
others_reactions: Array<OthersReactions>,
};
2021-04-23 21:59:48 +02:00
declare type CommentListParams = {
2022-02-07 19:03:10 +01:00
page: number, // pagination: which page of results
page_size: number, // pagination: nr of comments to show in a page (max 200)
claim_id?: string, // claim id of claim being commented on
channel_name?: string, // signing channel name of claim (enables 'commentsEnabled' check)
channel_id?: string, // signing channel claim id of claim (enables 'commentsEnabled' check)
author_claim_id?: string, // filters comments to just this author
parent_id?: ?string, // filters comments to those under this thread
2022-02-07 19:03:10 +01:00
top_level?: boolean, // filters to only top level comments
hidden?: boolean, // if true, will show hidden comments as well
2022-03-03 16:16:02 +01:00
sort_by?: ?number, // @see: ui/constants/comments.js::SORT_BY
2021-04-23 21:59:48 +02:00
};
declare type CommentListResponse = {
items: Array<Comment>,
page: number,
page_size: number,
2022-02-07 19:03:10 +01:00
total_items: number, // Grand total for the claim being commented on.
total_filtered_items: number, // Total for filtered queries (e.g. top_level=true, parent_id=xxx, etc.).
total_pages: number,
has_hidden_comments: boolean,
2021-04-23 21:59:48 +02:00
};
declare type CommentByIdParams = {
comment_id: string,
with_ancestors: boolean,
2022-02-07 19:03:10 +01:00
};
declare type CommentByIdResponse = {
item: Comment,
items: Comment,
ancestors: Array<Comment>,
2022-02-07 19:03:10 +01:00
};
declare type CommentPinParams = {
comment_id: string,
channel_id: string,
channel_name: string,
remove?: boolean,
signature: string,
signing_ts: string,
2022-02-07 19:03:10 +01:00
};
declare type CommentPinResponse = {
items: Comment, // "items" is an inherited typo to match SDK. Will be "item" in a new version.
2022-02-07 19:03:10 +01:00
};
declare type CommentEditParams = {
comment: string,
comment_id: string,
signature: string,
signing_ts: string,
2022-02-07 19:03:10 +01:00
};
2022-02-07 19:03:10 +01:00
declare type CommentEditResponse = Comment;
2021-04-23 21:59:48 +02:00
declare type CommentAbandonParams = {
comment_id: string,
creator_channel_id?: string,
creator_channel_name?: string,
signature?: string,
signing_ts?: string,
mod_channel_id?: string,
mod_channel_name?: string,
2021-04-23 21:59:48 +02:00
};
declare type MentionedChannel = {
channel_name: string,
channel_id: string,
};
2021-04-23 21:59:48 +02:00
declare type CommentCreateParams = {
comment: string,
claim_id: string,
parent_id?: string,
signature: string,
signing_ts: string,
2021-04-23 21:59:48 +02:00
support_tx_id?: string,
mentioned_channels?: Array<MentionedChannel>,
2021-04-23 21:59:48 +02:00
};
declare type SuperListParams = {};
declare type SuperListResponse = {
page: number,
page_size: number,
total_pages: number,
total_items: number,
total_amount: number,
items: Array<Comment>,
has_hidden_comments: boolean,
};
declare type ModerationBlockParams = {
// Publisher, Moderator, or Commentron Admin
mod_channel_id: string,
mod_channel_name: string,
// Offender being blocked
blocked_channel_id: string,
blocked_channel_name: string,
// Creator that Moderator is delegated from. Used for delegated moderation
creator_channel_id?: string,
creator_channel_name?: string,
// ID of comment to remove as part of this block
offending_comment_id?: string,
// Blocks identity from comment universally, requires Admin rights on commentron instance
block_all?: boolean,
time_out?: ?number,
// If true will delete all comments of the offender, requires Admin rights on commentron for universal delete
delete_all?: boolean,
// The usual signature stuff
signature: string,
signing_ts: string,
};
declare type ModerationBlockResponse = {
deleted_comment_ids: Array<string>,
banned_channel_id: string,
all_blocked: boolean,
banned_from: string,
};
declare type BlockedListArgs = {
// Publisher, Moderator or Commentron Admin
mod_channel_id: string,
mod_channel_name: string,
// Creator that Moderator is delegated from. Used for delegated moderation
creator_channel_id?: string,
creator_channel_name?: string,
signature: string,
signing_ts: string,
};
2021-04-20 10:40:53 +02:00
declare type ModerationAddDelegateParams = Authorization & {
2021-05-25 08:17:36 +02:00
mod_channel_id: string,
mod_channel_name: string,
};
declare type ModerationRemoveDelegateParams = Authorization & {
2021-05-25 08:17:36 +02:00
mod_channel_id: string,
mod_channel_name: string,
};
declare type ModerationListDelegatesParams = Authorization;
2021-05-25 08:17:36 +02:00
declare type ModerationAmIParams = {
channel_name: string,
channel_id: string,
signature: string,
2022-02-07 19:03:10 +01:00
signing_ts: string,
2021-05-25 08:17:36 +02:00
};
2021-04-20 10:40:53 +02:00
declare type SettingsParams = {
channel_name?: string,
2021-04-20 10:40:53 +02:00
channel_id: string,
signature?: string,
signing_ts?: string,
};
declare type SettingsResponse = {
words?: string,
comments_enabled: boolean,
min_tip_amount_comment: number,
min_tip_amount_super_chat: number,
slow_mode_min_gap: number,
curse_jar_amount: number,
filters_enabled?: boolean,
2021-04-20 10:40:53 +02:00
};
declare type UpdateSettingsParams = {
channel_name: string,
channel_id: string,
signature: string,
signing_ts: string,
comments_enabled?: boolean,
min_tip_amount_comment?: number,
min_tip_amount_super_chat?: number,
slow_mode_min_gap?: number,
2022-02-23 07:29:14 +01:00
time_since_first_comment?: number,
2022-02-07 19:03:10 +01:00
};
2021-04-20 10:40:53 +02:00
declare type BlockWordParams = {
channel_name: string,
channel_id: string,
signature: string,
signing_ts: string,
words: string, // CSV list of containing words to block comment on content
};