diff options
author | Eric Bailey <git@esb.lol> | 2023-08-28 20:41:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 18:41:28 -0700 |
commit | 1c460c40f44b55f07c335b0065321ffb436c172d (patch) | |
tree | be8ae2ac8171f16166013273acad05286402dcde /src/view/com/util | |
parent | cc2838761b214c436e1f854e951f587cc1aba3d2 (diff) | |
download | voidsky-1c460c40f44b55f07c335b0065321ffb436c172d.tar.zst |
Make posts behave more like links (#1316)
* use cursor for post cards * ignore type error * handle meta keys on non native links (cherry picked from commit daccafea0b7ab21af6572767e496d20f32ead353) * remove cursor on non-post notifications, not quite right * Simplify link handling --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/view/com/util')
-rw-r--r-- | src/view/com/util/Link.tsx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/view/com/util/Link.tsx b/src/view/com/util/Link.tsx index ead85d0b5..321b6ab63 100644 --- a/src/view/com/util/Link.tsx +++ b/src/view/com/util/Link.tsx @@ -259,15 +259,21 @@ function onPressInner( e?: Event, ) { let shouldHandle = false + const isLeftClick = + // @ts-ignore Web only -prf + Platform.OS === 'web' && (e.button == null || e.button === 0) + // @ts-ignore Web only -prf + const isMiddleClick = Platform.OS === 'web' && e.button === 1 + const isMetaKey = + // @ts-ignore Web only -prf + Platform.OS === 'web' && (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) + const newTab = isMetaKey || isMiddleClick if (Platform.OS !== 'web' || !e) { shouldHandle = e ? !e.defaultPrevented : true } else if ( !e.defaultPrevented && // onPress prevented default - // @ts-ignore Web only -prf - !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && // ignore clicks with modifier keys - // @ts-ignore Web only -prf - (e.button == null || e.button === 0) && // ignore everything but left clicks + (isLeftClick || isMiddleClick) && // ignore everything but left and middle clicks // @ts-ignore Web only -prf [undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle "target=_blank" etc. ) { @@ -277,7 +283,7 @@ function onPressInner( if (shouldHandle) { href = convertBskyAppUrlIfNeeded(href) - if (href.startsWith('http') || href.startsWith('mailto')) { + if (newTab || href.startsWith('http') || href.startsWith('mailto')) { Linking.openURL(href) } else { store.shell.closeModal() // close any active modals |