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'
|
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'
|
2023-01-10 13:27:47 +01:00
|
|
|
import { useFollowedTagsQuery } from '@utils/queryHooks/tags'
|
2022-12-28 23:41:36 +01:00
|
|
|
import { useAccountStorage } from '@utils/storage/actions'
|
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'
|
|
|
|
|
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-12-28 23:41:36 +01:00
|
|
|
const [pageMe, setPageMe] = useAccountStorage.object('page_me')
|
2021-11-15 23:43:35 +01:00
|
|
|
|
2022-12-10 20:19:18 +01:00
|
|
|
useListsQuery({
|
|
|
|
options: {
|
2022-12-28 23:41:36 +01:00
|
|
|
onSuccess: data => setPageMe({ ...pageMe, lists: { shown: !!data?.length } })
|
2021-11-15 23:43:35 +01:00
|
|
|
}
|
2022-12-10 20:19:18 +01:00
|
|
|
})
|
2023-01-10 13:27:47 +01:00
|
|
|
useFollowedTagsQuery({
|
|
|
|
options: {
|
|
|
|
onSuccess: data =>
|
|
|
|
setPageMe({ ...pageMe, followedTags: { shown: !!data.pages[0].body.length } })
|
|
|
|
}
|
|
|
|
})
|
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 =>
|
2022-12-28 23:41:36 +01:00
|
|
|
setPageMe({
|
|
|
|
...pageMe,
|
|
|
|
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-28 23:41:36 +01:00
|
|
|
const [instancePush] = useAccountStorage.object('push')
|
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
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='mail'
|
|
|
|
iconBack='chevron-right'
|
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
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='bookmark'
|
|
|
|
iconBack='chevron-right'
|
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
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='heart'
|
|
|
|
iconBack='chevron-right'
|
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
|
|
|
/>
|
2023-01-16 18:56:15 +01:00
|
|
|
{pageMe?.lists?.shown ? (
|
2021-05-15 23:08:13 +02:00
|
|
|
<MenuRow
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='list'
|
|
|
|
iconBack='chevron-right'
|
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}
|
2023-01-16 18:56:15 +01:00
|
|
|
{pageMe?.followedTags?.shown ? (
|
2022-12-10 20:19:18 +01:00
|
|
|
<MenuRow
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='hash'
|
|
|
|
iconBack='chevron-right'
|
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}
|
2023-01-16 18:56:15 +01:00
|
|
|
{pageMe?.announcements?.shown ? (
|
2021-05-15 23:08:13 +02:00
|
|
|
<MenuRow
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront='clipboard'
|
|
|
|
iconBack='chevron-right'
|
2021-05-15 23:08:13 +02:00
|
|
|
title={t('screenAnnouncements:heading')}
|
|
|
|
content={
|
2022-12-28 23:41:36 +01:00
|
|
|
pageMe.announcements.unread
|
2022-12-23 15:53:40 +01:00
|
|
|
? t('screenTabs:me.root.announcements.content.unread', {
|
2022-12-28 23:41:36 +01:00
|
|
|
amount: pageMe.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
|
2023-01-25 00:15:46 +01:00
|
|
|
iconFront={instancePush ? 'bell' : 'bell-off'}
|
|
|
|
iconBack='chevron-right'
|
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
|