Store last seen at

This commit is contained in:
KoalaSat 2023-01-29 13:20:29 +01:00
parent 9c883d2dc5
commit a66d685810
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
3 changed files with 17 additions and 3 deletions

View File

@ -35,6 +35,15 @@ export const updateConfig: (
return db.execute(configQuery, [config.satoshi, config.show_public_images, config.show_sensitive])
}
export const updateLastNotificationConfig: (
lastNotificationSeenAt: number,
db: QuickSQLiteConnection,
) => Promise<QueryResult> = async (lastNotificationSeenAt, db) => {
const configQuery = `UPDATE nostros_config SET last_notification_seen_at = ?`
return db.execute(configQuery, [lastNotificationSeenAt])
}
export const getNotificationsCount: (
db: QuickSQLiteConnection,
pubKey: string,

View File

@ -57,7 +57,7 @@ export const GlobalFeed: React.FC<GlobalFeedProps> = ({ navigation, setProfileCa
}, [pageSize])
const updateLastLoad: () => void = () => {
setLastLoadAt(getUnixTime(new Date()))
setLastLoadAt(getUnixTime(new Date()) - 5)
}
const onRefresh = useCallback(() => {

View File

@ -22,6 +22,8 @@ import { useTranslation } from 'react-i18next'
import { navigate } from '../../lib/Navigation'
import { useFocusEffect } from '@react-navigation/native'
import { getLastReaction } from '../../Functions/DatabaseFunctions/Reactions'
import { updateLastNotificationConfig } from '../../Functions/DatabaseFunctions/Config'
import { getUnixTime } from 'date-fns'
export const NotificationsFeed: React.FC = () => {
const theme = useTheme()
@ -38,8 +40,11 @@ export const NotificationsFeed: React.FC = () => {
useFocusEffect(
React.useCallback(() => {
subscribeNotes()
loadNotes()
if (database) {
subscribeNotes()
loadNotes()
updateLastNotificationConfig(getUnixTime(new Date()), database)
}
return () =>
relayPool?.unsubscribe([