chore: on android use notification to display file upload progress instead of toast (#2628) [skip e2e]
This commit is contained in:
@@ -14,6 +14,7 @@ import { MobileDevice, MobileDeviceEvent } from './Lib/MobileDevice'
|
||||
import { IsDev } from './Lib/Utils'
|
||||
import { ReceivedSharedItemsHandler } from './ReceivedSharedItemsHandler'
|
||||
import { ReviewService } from './ReviewService'
|
||||
import notifee, { EventType } from '@notifee/react-native'
|
||||
|
||||
const LoggingEnabled = IsDev
|
||||
|
||||
@@ -117,6 +118,34 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
||||
}
|
||||
}, [webViewRef, stateService, device, androidBackHandlerService, colorSchemeService])
|
||||
|
||||
useEffect(() => {
|
||||
return notifee.onForegroundEvent(({ type, detail }) => {
|
||||
if (type !== EventType.ACTION_PRESS) {
|
||||
return
|
||||
}
|
||||
|
||||
const { notification, pressAction } = detail
|
||||
|
||||
if (!notification || !pressAction) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pressAction.id !== 'open-file') {
|
||||
return
|
||||
}
|
||||
|
||||
webViewRef.current?.postMessage(
|
||||
JSON.stringify({
|
||||
reactNativeEvent: ReactNativeToWebEvent.OpenFilePreview,
|
||||
messageType: 'event',
|
||||
messageData: {
|
||||
id: notification.id,
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const observer = device.addMobileDeviceEventReceiver((event) => {
|
||||
if (event === MobileDeviceEvent.RequestsWebViewReload) {
|
||||
|
||||
Reference in New Issue
Block a user