Add support for new-tab clicks on feeds (#4462)
This commit is contained in:
parent
59f49bef68
commit
90ec22a674
3 changed files with 48 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
import {Linking} from 'react-native'
|
||||
import {GestureResponderEvent, Linking} from 'react-native'
|
||||
|
||||
import {isNative, isWeb} from './detection'
|
||||
|
||||
export async function getInitialURL(): Promise<string | undefined> {
|
||||
|
@ -23,3 +24,15 @@ export function clearHash() {
|
|||
window.location.hash = ''
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldClickOpenNewTab(e: GestureResponderEvent) {
|
||||
/**
|
||||
* A `GestureResponderEvent`, but cast to `any` to avoid using a bunch
|
||||
* of @ts-ignore below.
|
||||
*/
|
||||
const event = e as any
|
||||
const isMiddleClick = isWeb && event.button === 1
|
||||
const isMetaKey =
|
||||
isWeb && (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
||||
return isMetaKey || isMiddleClick
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue