1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Improve push experience

This commit is contained in:
Zhiyuan Zheng
2021-03-02 01:17:06 +01:00
parent 82cefdc80c
commit ea018a71fa
38 changed files with 417 additions and 218 deletions

View File

@ -17,29 +17,25 @@ import { AppState, Linking } from 'react-native'
const ScreenMeSettingsPush: React.FC = () => {
const { t } = useTranslation('meSettingsPush')
const [appStateVisible, setAppStateVisible] = useState(AppState.currentState)
useEffect(() => {
AppState.addEventListener('change', state => setAppStateVisible(state))
return () => {
AppState.removeEventListener('change', state => setAppStateVisible(state))
}
}, [])
const [pushEnabled, setPushEnabled] = useState<boolean>()
const [pushCanAskAgain, setPushCanAskAgain] = useState<boolean>()
useEffect(() => {
const checkPush = async () => {
const settings = await Notifications.getPermissionsAsync()
layoutAnimation()
setPushEnabled(settings.granted)
setPushCanAskAgain(settings.canAskAgain)
}
checkPush()
}, [appStateVisible])
const dispatch = useDispatch()
const instancePush = useSelector(getInstancePush)
const [pushEnabled, setPushEnabled] = useState<boolean>()
const [pushCanAskAgain, setPushCanAskAgain] = useState<boolean>()
const checkPush = async () => {
const settings = await Notifications.getPermissionsAsync()
layoutAnimation()
setPushEnabled(settings.granted)
setPushCanAskAgain(settings.canAskAgain)
}
useEffect(() => {
checkPush()
AppState.addEventListener('change', () => checkPush())
return () => {
AppState.removeEventListener('change', () => {})
}
}, [])
const isLoading = instancePush?.global.loading || instancePush?.decode.loading
const alerts = useMemo(() => {