Fix 1304 refresh notifications when a notif is clicked or received (#1339)

* refresh notifications when a notif is clicked

* make notification syncing smarter

* allow enabled appview proxy on mobile

* put back syncqueue code
This commit is contained in:
Ansh 2023-08-30 18:04:33 -07:00 committed by GitHub
parent 4bec7c1d85
commit 4ac82536c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -10,7 +10,6 @@
import {useState, useCallback, useEffect} from 'react' import {useState, useCallback, useEffect} from 'react'
import {BskyAgent} from '@atproto/api' import {BskyAgent} from '@atproto/api'
import {isWeb} from 'platform/detection'
import * as Storage from 'lib/storage' import * as Storage from 'lib/storage'
export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] { export function useDebugHeaderSetting(agent: BskyAgent): [boolean, () => void] {
@ -51,9 +50,6 @@ export function setDebugHeader(agent: BskyAgent, enabled: boolean) {
} }
export async function applyDebugHeader(agent: BskyAgent) { export async function applyDebugHeader(agent: BskyAgent) {
if (!isWeb) {
return
}
if (await isEnabled()) { if (await isEnabled()) {
agent.api.xrpc.setHeader('x-appview-proxy', 'true') agent.api.xrpc.setHeader('x-appview-proxy', 'true')
} }

View file

@ -61,10 +61,13 @@ export function init(store: RootStoreModel) {
}) })
}) })
// handle notifications that are tapped on, regardless of whether the app is in the foreground or background // handle notifications that are received, both in the foreground or background
Notifications.addNotificationReceivedListener(event => { Notifications.addNotificationReceivedListener(event => {
store.log.debug('Notifications: received', event) store.log.debug('Notifications: received', event)
if (event.request.trigger.type === 'push') { if (event.request.trigger.type === 'push') {
// refresh notifications in the background
store.me.notifications.syncQueue()
// handle payload-based deeplinks
let payload let payload
if (isIOS) { if (isIOS) {
payload = event.request.trigger.payload payload = event.request.trigger.payload
@ -78,6 +81,7 @@ export function init(store: RootStoreModel) {
} }
}) })
// handle notifications that are tapped on
const sub = Notifications.addNotificationResponseReceivedListener( const sub = Notifications.addNotificationResponseReceivedListener(
response => { response => {
store.log.debug( store.log.debug(
@ -91,7 +95,8 @@ export function init(store: RootStoreModel) {
'User pressed a notification, opening notifications tab', 'User pressed a notification, opening notifications tab',
) )
track('Notificatons:OpenApp') track('Notificatons:OpenApp')
resetToTab('NotificationsTab') store.me.notifications.refresh() // refresh notifications
resetToTab('NotificationsTab') // open notifications tab
} }
}, },
) )