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

Switch to shared hooks

This commit is contained in:
Zhiyuan Zheng
2021-01-11 21:36:57 +01:00
parent fdce172c57
commit 284d6e46e0
47 changed files with 1053 additions and 727 deletions

View File

@ -14,7 +14,7 @@ import ScreenLocal from '@screens/Local'
import ScreenMe from '@screens/Me'
import ScreenNotifications from '@screens/Notifications'
import ScreenPublic from '@screens/Public'
import hookTimeline from '@utils/queryHooks/timeline'
import { useTimelineQuery } from '@utils/queryHooks/timeline'
import {
getLocalActiveIndex,
getLocalNotification,
@ -100,7 +100,7 @@ const Index: React.FC<Props> = ({ localCorrupt }) => {
}, [])
// On launch check if there is any unread noficiations
const queryNotification = hookTimeline({
const queryNotification = useTimelineQuery({
page: 'Notifications',
options: {
enabled: localActiveIndex !== null ? true : false,
@ -112,9 +112,7 @@ const Index: React.FC<Props> = ({ localCorrupt }) => {
const prevNotification = useSelector(getLocalNotification)
useEffect(() => {
if (queryNotification.data?.pages) {
const flattenData = queryNotification.data.pages.flatMap(d => [
...d?.toots
])
const flattenData = queryNotification.data.pages.flatMap(d => [...d])
const latestNotificationTime = flattenData.length
? (flattenData[0] as Mastodon.Notification).created_at
: undefined