-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Report and block users (#4056)
* feat: ReportUserModal (#4051) * feat: ReportUserModal * formatting * lint * remove unnecessary check * update conditional * remove need to pass onClose * capitalize values * feat: Add block and report to user profile (#4054) * feat: ReportUserModal * formatting * lint * remove unnecessary check * update conditional * remove need to pass onClose * capitalize values * feat: Add block and report to user profile * feat: Block, report, share on profile available for everyone (#4059) * feat: Block, report, share on profile available for everyone * update copy * update to still show share button when only 1 opt available * fix: Should not show following when blocked (#4064) * fix: Should not show following when blocked * update syntax * fix: No longer open report modal when reporting user (#4069) * fix: No longer open report modal when reporting user * add block request key to status map * feat: add block user option on post context menu (#4053) * feat: ReportUserModal * formatting * lint * remove unnecessary check * update conditional * feat: add block user option in post context menu * remove need to pass onClose * capitalize values * feat: add optimistic update on unblock * feat: refactor avoiding additional query * fix: ssr error * feat: add contentPreference data for author * feat: hide follow option for blocked users, change source block label; * feat: clear cache on block * feat: block on custom feed feature * test: update label for block/unblock * refactor: invalidate cache is not a utility * feat: added new labels and block directly without report modal * feat: hide post from feed and add undo action to toast --------- Co-authored-by: Amar Trebinjac <amartrebinjac@gmail.com> * update hateful key * Update packages/shared/src/components/modals/report/ReportUserModal.tsx Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> * fix: cache invalidation (#4078) * move query invalidation * remove unused hook * remove follow button on profile when blocked * feat: Remove default add btn in advanced settings, add block btn on u… (#4075) * feat: Remove default add btn in advanced settings, add block btn on users * make reusable component * invalidate specific feed * undo feed key * use onsettled to close * add author block * use username instead of name * try invalidate userblocked request key * use correct username * remove unnecessary feed invalidation * fix: block button inside link in source list (#4077) * feat: Remove default add btn in advanced settings, add block btn on users * make reusable component * fix: button inside link * fix: lint unused var * fix: moved key from children to parent * fix: UserList open in new tab --------- Co-authored-by: Amar Trebinjac <amartrebinjac@gmail.com> Co-authored-by: Amar Trebinjac <36768584+AmarTrebinjac@users.noreply.github.com> * fix: invalidation of blocked users for settings --------- Co-authored-by: Luca Pagliaro <pagliaroluca@gmail.com> Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> Co-authored-by: capJavert <dev@kickass.website>
- Loading branch information
1 parent
ba8f283
commit c0e04c6
Showing
23 changed files
with
582 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/shared/src/components/contentPreference/BlockButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
import type { ContentPreferenceType } from '../../graphql/contentPreference'; | ||
import { ContentPreferenceStatus } from '../../graphql/contentPreference'; | ||
import type { ButtonProps } from '../buttons/Button'; | ||
import { Button } from '../buttons/Button'; | ||
import { ButtonVariant, ButtonSize } from '../buttons/common'; | ||
import { useContentPreference } from '../../hooks/contentPreference/useContentPreference'; | ||
|
||
type BlockButtonProps = { | ||
feedId: string; | ||
entityId: string; | ||
entityName: string; | ||
status?: ContentPreferenceStatus; | ||
entityType: ContentPreferenceType; | ||
} & Pick<ButtonProps<'button'>, 'variant' | 'size' | 'className'>; | ||
|
||
const BlockButton = ({ | ||
variant = ButtonVariant.Secondary, | ||
size = ButtonSize.Small, | ||
feedId, | ||
entityId, | ||
entityName, | ||
entityType, | ||
status, | ||
...attrs | ||
}: BlockButtonProps): ReactElement => { | ||
const { block, unblock } = useContentPreference(); | ||
|
||
return ( | ||
<Button | ||
{...attrs} | ||
onClick={() => { | ||
if (status === ContentPreferenceStatus.Blocked) { | ||
unblock({ | ||
id: entityId, | ||
entity: entityType, | ||
entityName, | ||
feedId, | ||
}); | ||
} else { | ||
block({ | ||
id: entityId, | ||
entity: entityType, | ||
entityName, | ||
feedId, | ||
}); | ||
} | ||
}} | ||
type="button" | ||
variant={variant} | ||
size={size} | ||
> | ||
{status === ContentPreferenceStatus.Blocked ? 'Unblock' : 'Block'} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default BlockButton; |
Oops, something went wrong.