2021-01-19 01:13:45 +01:00
|
|
|
import { MenuContainer, MenuRow } from '@components/Menu'
|
2020-11-29 13:11:23 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
2022-04-30 23:47:52 +02:00
|
|
|
import { useAppDispatch } from '@root/store'
|
2021-01-19 01:13:45 +01:00
|
|
|
import { useAnnouncementQuery } from '@utils/queryHooks/announcement'
|
2021-02-28 17:41:21 +01:00
|
|
|
import { useListsQuery } from '@utils/queryHooks/lists'
|
2022-12-10 20:19:18 +01:00
|
|
|
import { useFollowedTagsQuery } from '@utils/queryHooks/tags'
|
2022-12-25 17:40:53 +01:00
|
|
|
import { getInstanceMePage, updateInstanceMePage } from '@utils/slices/instancesSlice'
|
2021-12-15 23:22:47 +01:00
|
|
|
import { getInstancePush } from '@utils/slices/instancesSlice'
|
2022-12-23 15:53:40 +01:00
|
|
|
import React from 'react'
|
2020-11-29 13:11:23 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2022-04-30 23:47:52 +02:00
|
|
|
import { useSelector } from 'react-redux'
|
2020-11-29 13:11:23 +01:00
|
|
|
|
2020-11-29 18:08:31 +01:00
|
|
|
const Collections: React.FC = () => {
|
2022-12-23 15:53:40 +01:00
|
|
|
const { t } = useTranslation(['screenAnnouncements', 'screenTabs'])
|
2021-08-29 15:25:38 +02:00
|
|
|
const navigation = useNavigation<any>()
|
2020-11-22 00:46:23 +01:00
|
|
|
|
2022-04-30 23:47:52 +02:00
|
|
|
const dispatch = useAppDispatch()
|
2022-01-16 23:26:05 +01:00
|
|
|
const mePage = useSelector(getInstanceMePage)
|
2021-11-15 23:43:35 +01:00
|
|
|
|
2022-12-10 20:19:18 +01:00
|
|
|
useFollowedTagsQuery({
|
2021-02-28 17:41:21 +01:00
|
|
|
options: {
|
2022-12-10 20:19:18 +01:00
|
|
|
onSuccess: data =>
|
|
|
|
dispatch(
|
|
|
|
updateInstanceMePage({
|
|
|
|
followedTags: { shown: !!data?.pages?.[0].body?.length }
|
|
|
|
})
|
|
|
|
)
|
2021-02-28 17:41:21 +01:00
|
|
|
}
|
2021-01-31 03:09:35 +01:00
|
|
|
})
|
2022-12-10 20:19:18 +01:00
|
|
|
useListsQuery({
|
|
|
|
options: {
|
|
|
|
onSuccess: data =>
|
|
|
|
dispatch(
|
|
|
|
updateInstanceMePage({
|
|
|
|
lists: { shown: !!data?.length }
|
|
|
|
})
|
|
|
|
)
|
2021-11-15 23:43:35 +01:00
|
|
|
}
|
2022-12-10 20:19:18 +01:00
|
|
|
})
|
|
|
|
useAnnouncementQuery({
|
2021-02-28 17:41:21 +01:00
|
|
|
showAll: true,
|
|
|
|
options: {
|
2022-12-10 20:19:18 +01:00
|
|
|
onSuccess: data =>
|
|
|
|
dispatch(
|
|
|
|
updateInstanceMePage({
|
|
|
|
announcements: {
|
|
|
|
shown: !!data?.length ? true : false,
|
|
|
|
unread: data?.filter(announcement => !announcement.read).length
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
2021-02-28 17:41:21 +01:00
|
|
|
}
|
|
|
|
})
|
2020-12-23 15:57:20 +01:00
|
|
|
|
2022-12-09 21:09:00 +01:00
|
|
|
const instancePush = useSelector(getInstancePush, (prev, next) => prev?.global === next?.global)
|
2021-12-15 23:22:47 +01:00
|
|
|
|
2020-11-22 00:46:23 +01:00
|
|
|
return (
|
|
|
|
<MenuContainer>
|
2020-12-03 01:28:56 +01:00
|
|
|
<MenuRow
|
2021-01-03 02:00:26 +01:00
|
|
|
iconFront='Mail'
|
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.conversations.name')}
|
2021-01-30 01:29:15 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-Conversations')}
|
2020-11-29 13:11:23 +01:00
|
|
|
/>
|
2020-12-03 01:28:56 +01:00
|
|
|
<MenuRow
|
2021-01-03 02:00:26 +01:00
|
|
|
iconFront='Bookmark'
|
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.bookmarks.name')}
|
2021-01-30 01:29:15 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-Bookmarks')}
|
2020-11-29 13:11:23 +01:00
|
|
|
/>
|
2020-12-03 01:28:56 +01:00
|
|
|
<MenuRow
|
2021-02-10 00:40:44 +01:00
|
|
|
iconFront='Heart'
|
2021-01-03 02:00:26 +01:00
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.favourites.name')}
|
2021-01-30 01:29:15 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-Favourites')}
|
2020-11-29 13:11:23 +01:00
|
|
|
/>
|
2021-11-15 23:43:35 +01:00
|
|
|
{mePage.lists.shown ? (
|
2021-05-15 23:08:13 +02:00
|
|
|
<MenuRow
|
|
|
|
iconFront='List'
|
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.lists.name')}
|
2022-12-02 00:13:59 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-List-List')}
|
2021-05-15 23:08:13 +02:00
|
|
|
/>
|
|
|
|
) : null}
|
2022-12-10 20:19:18 +01:00
|
|
|
{mePage.followedTags.shown ? (
|
|
|
|
<MenuRow
|
|
|
|
iconFront='Hash'
|
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.followedTags.name')}
|
2022-12-10 20:19:18 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-FollowedTags')}
|
|
|
|
/>
|
|
|
|
) : null}
|
2021-11-15 23:43:35 +01:00
|
|
|
{mePage.announcements.shown ? (
|
2021-05-15 23:08:13 +02:00
|
|
|
<MenuRow
|
|
|
|
iconFront='Clipboard'
|
|
|
|
iconBack='ChevronRight'
|
|
|
|
title={t('screenAnnouncements:heading')}
|
|
|
|
content={
|
2021-11-15 23:43:35 +01:00
|
|
|
mePage.announcements.unread
|
2022-12-23 15:53:40 +01:00
|
|
|
? t('screenTabs:me.root.announcements.content.unread', {
|
2021-11-15 23:43:35 +01:00
|
|
|
amount: mePage.announcements.unread
|
2021-05-15 23:08:13 +02:00
|
|
|
})
|
2022-12-23 15:53:40 +01:00
|
|
|
: t('screenTabs:me.root.announcements.content.read')
|
2021-05-15 23:08:13 +02:00
|
|
|
}
|
2022-12-04 17:56:47 +01:00
|
|
|
onPress={() => navigation.navigate('Screen-Announcements', { showAll: true })}
|
2021-05-15 23:08:13 +02:00
|
|
|
/>
|
|
|
|
) : null}
|
2021-12-15 23:22:47 +01:00
|
|
|
<MenuRow
|
|
|
|
iconFront={instancePush ? 'Bell' : 'BellOff'}
|
|
|
|
iconBack='ChevronRight'
|
2022-12-23 15:53:40 +01:00
|
|
|
title={t('screenTabs:me.stacks.push.name')}
|
2022-12-21 01:07:12 +01:00
|
|
|
content={
|
|
|
|
typeof instancePush.global === 'boolean'
|
2022-12-23 15:53:40 +01:00
|
|
|
? t('screenTabs:me.root.push.content', {
|
|
|
|
defaultValue: 'false',
|
|
|
|
context: instancePush.global.toString()
|
|
|
|
})
|
2022-12-21 01:07:12 +01:00
|
|
|
: undefined
|
|
|
|
}
|
2021-12-15 23:22:47 +01:00
|
|
|
onPress={() => navigation.navigate('Tab-Me-Push')}
|
|
|
|
/>
|
2020-11-22 00:46:23 +01:00
|
|
|
</MenuContainer>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-11-29 18:08:31 +01:00
|
|
|
export default Collections
|