diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-06-10 11:44:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-10 11:44:13 -0700 |
commit | 90ec22a6749555f48bfd21eec81f877f8eae0524 (patch) | |
tree | 97aa29c86e4ba861dde9e3df470951b9345cb3c2 /src/platform/urls.tsx | |
parent | 59f49bef68500c1719ed44470121f553208edc85 (diff) | |
download | voidsky-90ec22a6749555f48bfd21eec81f877f8eae0524.tar.zst |
Add support for new-tab clicks on feeds (#4462)
Diffstat (limited to 'src/platform/urls.tsx')
-rw-r--r-- | src/platform/urls.tsx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/platform/urls.tsx b/src/platform/urls.tsx index fd844d933..fd9d297aa 100644 --- a/src/platform/urls.tsx +++ b/src/platform/urls.tsx @@ -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 +} |