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

When replying to CW content, CW will be added

This commit is contained in:
Zhiyuan Zheng
2021-02-27 17:25:01 +01:00
parent f3fa6bc662
commit 4eea2bf58c
6 changed files with 45 additions and 24 deletions

View File

@ -1,4 +1,3 @@
import apiInstance from '@api/instance'
import { toast, toastConfig } from '@components/toast'
import {
NavigationContainer,
@ -9,6 +8,7 @@ import ScreenAnnouncements from '@screens/Announcements'
import ScreenCompose from '@screens/Compose'
import ScreenImagesViewer from '@screens/ImagesViewer'
import ScreenTabs from '@screens/Tabs'
import { useAnnouncementQuery } from '@utils/queryHooks/announcement'
import { updatePreviousTab } from '@utils/slices/contextsSlice'
import { updateAccountPreferences } from '@utils/slices/instances/updateAccountPreferences'
import { getInstanceActive } from '@utils/slices/instancesSlice'
@ -117,28 +117,28 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
}, [localCorrupt])
// On launch check if there is any unread announcements
useEffect(() => {
instanceActive !== -1 &&
apiInstance<Mastodon.Announcement[]>({
method: 'get',
url: `announcements`
})
.then(res => {
if (res.body.filter(announcement => !announcement.read).length) {
navigationRef.current?.navigate('Screen-Announcements', {
showAll: false
})
}
})
.catch(() => {})
}, [])
useAnnouncementQuery({
showAll: false,
options: {
notifyOnChangeProps: [],
select: announcements =>
announcements.filter(announcement => !announcement.read),
onSuccess: data => {
if (data.length) {
navigationRef.current?.navigate('Screen-Announcements', {
showAll: false
})
}
}
}
})
// Lazily update users's preferences, for e.g. composing default visibility
useEffect(() => {
if (instanceActive !== -1) {
dispatch(updateAccountPreferences())
}
}, [])
}, [instanceActive])
// Callbacks
const navigationContainerOnReady = useCallback(