Merge branch 'hailey/list-hide-stuff' into hailey/list-hide-stuff-2
This commit is contained in:
@@ -23,7 +23,7 @@ type Context = {
|
|||||||
|
|
||||||
const Context = React.createContext<Context>({} as Context)
|
const Context = React.createContext<Context>({} as Context)
|
||||||
|
|
||||||
export const useScreenHider = () => React.useContext(Context)
|
export const useHider = () => React.useContext(Context)
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
modui,
|
modui,
|
||||||
@@ -73,11 +73,11 @@ export function Outer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Content({children}: {children: React.ReactNode}) {
|
export function Content({children}: {children: React.ReactNode}) {
|
||||||
const ctx = useScreenHider()
|
const ctx = useHider()
|
||||||
return ctx.isContentVisible ? children : null
|
return ctx.isContentVisible ? children : null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Mask({children}: {children: React.ReactNode}) {
|
export function Mask({children}: {children: React.ReactNode}) {
|
||||||
const ctx = useScreenHider()
|
const ctx = useHider()
|
||||||
return ctx.isContentVisible ? null : children
|
return ctx.isContentVisible ? null : children
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,8 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useGoBack} from 'lib/hooks/useGoBack'
|
import {useGoBack} from 'lib/hooks/useGoBack'
|
||||||
import {
|
import {sanitizeHandle} from 'lib/strings/handles'
|
||||||
useListBlockMutation,
|
import {useListBlockMutation, useListMuteMutation} from 'state/queries/list'
|
||||||
useListDeleteMutation,
|
|
||||||
useListMuteMutation,
|
|
||||||
} from 'state/queries/list'
|
|
||||||
import {
|
import {
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
@@ -21,6 +18,7 @@ import {CenteredView} from 'view/com/util/Views'
|
|||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash'
|
import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash'
|
||||||
|
import {useHider} from '#/components/moderation/Hider'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export function ListHiddenScreen({
|
export function ListHiddenScreen({
|
||||||
@@ -42,9 +40,10 @@ export function ListHiddenScreen({
|
|||||||
const [isProcessing, setIsProcessing] = React.useState(false)
|
const [isProcessing, setIsProcessing] = React.useState(false)
|
||||||
const listBlockMutation = useListBlockMutation()
|
const listBlockMutation = useListBlockMutation()
|
||||||
const listMuteMutation = useListMuteMutation()
|
const listMuteMutation = useListMuteMutation()
|
||||||
const listDeleteMutation = useListDeleteMutation()
|
|
||||||
const {mutateAsync: removeSavedFeed} = useRemoveFeedMutation()
|
const {mutateAsync: removeSavedFeed} = useRemoveFeedMutation()
|
||||||
|
|
||||||
|
const {setIsContentVisible} = useHider()
|
||||||
|
|
||||||
const savedFeedConfig = preferences.savedFeeds.find(f => f.value === list.uri)
|
const savedFeedConfig = preferences.savedFeeds.find(f => f.value === list.uri)
|
||||||
|
|
||||||
const onUnsubscribe = async () => {
|
const onUnsubscribe = async () => {
|
||||||
@@ -81,24 +80,6 @@ export function ListHiddenScreen({
|
|||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDeleteList = async () => {
|
|
||||||
setIsProcessing(true)
|
|
||||||
try {
|
|
||||||
await listDeleteMutation.mutateAsync({uri: list.uri})
|
|
||||||
Toast.show(_(msg`List deleted`))
|
|
||||||
} catch (e) {
|
|
||||||
logger.error('Failed to delete list from saved feeds', {message: e})
|
|
||||||
Toast.show(
|
|
||||||
_(
|
|
||||||
msg`There was an issue. Please check your internet connection and try again.`,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
} finally {
|
|
||||||
setIsProcessing(false)
|
|
||||||
goBack()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const onRemoveList = async () => {
|
const onRemoveList = async () => {
|
||||||
if (!savedFeedConfig) return
|
if (!savedFeedConfig) return
|
||||||
try {
|
try {
|
||||||
@@ -135,7 +116,7 @@ export function ListHiddenScreen({
|
|||||||
/>
|
/>
|
||||||
<View style={[a.gap_sm, a.align_center]}>
|
<View style={[a.gap_sm, a.align_center]}>
|
||||||
<Text style={[a.font_bold, a.text_3xl]}>
|
<Text style={[a.font_bold, a.text_3xl]}>
|
||||||
<Trans>List hidden</Trans>
|
<Trans>List has been hidden</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
@@ -145,15 +126,16 @@ export function ListHiddenScreen({
|
|||||||
t.atoms.text_contrast_high,
|
t.atoms.text_contrast_high,
|
||||||
{lineHeight: 1.4},
|
{lineHeight: 1.4},
|
||||||
]}>
|
]}>
|
||||||
{isOwner ? (
|
|
||||||
<Trans>
|
<Trans>
|
||||||
The list you are trying to view (
|
This list - created by{' '}
|
||||||
<Text style={[a.font_bold, a.text_md]}>{list.name}</Text>) has
|
<Text style={[a.text_md, !isOwner && a.font_bold]}>
|
||||||
been hidden.
|
{isOwner
|
||||||
|
? _(msg`you`)
|
||||||
|
: sanitizeHandle(list.creator.handle, '@')}
|
||||||
|
</Text>{' '}
|
||||||
|
- contains possible violations of Bluesky's community guidelines
|
||||||
|
in its name or description.
|
||||||
</Trans>
|
</Trans>
|
||||||
) : (
|
|
||||||
<Trans>The list you are trying to view has been hidden.</Trans>
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -177,15 +159,14 @@ export function ListHiddenScreen({
|
|||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="medium"
|
size="medium"
|
||||||
label={_(msg`Delete List`)}
|
label={_(msg`Show list anyway`)}
|
||||||
onPress={onDeleteList}
|
onPress={() => setIsContentVisible(true)}
|
||||||
disabled={isProcessing}>
|
disabled={isProcessing}>
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Delete list</Trans>
|
<Trans>Show anyway</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : list.viewer?.muted || list.viewer?.blocked ? (
|
||||||
{list.viewer?.muted || list.viewer?.blocked ? (
|
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
Reference in New Issue
Block a user