mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Refine notifications
https://github.com/tooot-app/app/issues/306 https://github.com/tooot-app/app/issues/305 This one uses the positive filtering that is added since v3.5, that a such a filter won't be shown as there is no way to check if a user is an admin or not and showing a useless option for majority users won't be a good experience.
This commit is contained in:
@ -4,6 +4,7 @@ import MenuHeader from '@components/Menu/Header'
|
||||
import MenuRow from '@components/Menu/Row'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import {
|
||||
checkInstanceFeature,
|
||||
getInstanceNotificationsFilter,
|
||||
updateInstanceNotificationsFilter
|
||||
} from '@utils/slices/instancesSlice'
|
||||
@ -33,42 +34,63 @@ const ActionsNotificationsFilter: React.FC = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
const hasTypeStatus = useSelector(
|
||||
checkInstanceFeature('notification_type_status')
|
||||
)
|
||||
const hasTypeUpdate = useSelector(
|
||||
checkInstanceFeature('notification_type_update')
|
||||
)
|
||||
const options = useMemo(() => {
|
||||
return (
|
||||
instanceNotificationsFilter &&
|
||||
(
|
||||
[
|
||||
'follow',
|
||||
'follow_request',
|
||||
'favourite',
|
||||
'reblog',
|
||||
'mention',
|
||||
'poll',
|
||||
'follow_request'
|
||||
'status',
|
||||
'update'
|
||||
] as [
|
||||
'follow',
|
||||
'follow_request',
|
||||
'favourite',
|
||||
'reblog',
|
||||
'mention',
|
||||
'poll',
|
||||
'follow_request'
|
||||
'status',
|
||||
'update'
|
||||
]
|
||||
).map(type => (
|
||||
<MenuRow
|
||||
key={type}
|
||||
title={t(`content.notificationsFilter.content.${type}`)}
|
||||
switchValue={instanceNotificationsFilter[type]}
|
||||
switchOnValueChange={() =>
|
||||
dispatch(
|
||||
updateInstanceNotificationsFilter({
|
||||
...instanceNotificationsFilter,
|
||||
[type]: !instanceNotificationsFilter[type]
|
||||
})
|
||||
)
|
||||
)
|
||||
.filter(type => {
|
||||
switch (type) {
|
||||
case 'status':
|
||||
return hasTypeStatus
|
||||
case 'update':
|
||||
return hasTypeUpdate
|
||||
default:
|
||||
return true
|
||||
}
|
||||
/>
|
||||
))
|
||||
})
|
||||
.map(type => (
|
||||
<MenuRow
|
||||
key={type}
|
||||
title={t(`content.notificationsFilter.content.${type}`)}
|
||||
switchValue={instanceNotificationsFilter[type]}
|
||||
switchOnValueChange={() =>
|
||||
dispatch(
|
||||
updateInstanceNotificationsFilter({
|
||||
...instanceNotificationsFilter,
|
||||
[type]: !instanceNotificationsFilter[type]
|
||||
})
|
||||
)
|
||||
}
|
||||
/>
|
||||
))
|
||||
)
|
||||
}, [instanceNotificationsFilter])
|
||||
}, [instanceNotificationsFilter, hasTypeStatus, hasTypeUpdate])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -5,11 +5,8 @@ import ComponentInstance from '@components/Instance'
|
||||
import CustomText from '@components/Text'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import initQuery from '@utils/initQuery'
|
||||
import {
|
||||
getInstanceActive,
|
||||
getInstances,
|
||||
Instance
|
||||
} from '@utils/slices/instancesSlice'
|
||||
import { InstanceLatest } from '@utils/migrations/instances/migration'
|
||||
import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { useEffect, useRef } from 'react'
|
||||
@ -19,7 +16,7 @@ import { ScrollView } from 'react-native-gesture-handler'
|
||||
import { useSelector } from 'react-redux'
|
||||
|
||||
interface Props {
|
||||
instance: Instance
|
||||
instance: InstanceLatest
|
||||
selected?: boolean
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user