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>zio/stable
parent
cc2838761b
commit
1c460c40f4
|
@ -367,6 +367,7 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
pal.border,
|
pal.border,
|
||||||
pal.view,
|
pal.view,
|
||||||
item._showParentReplyLine && hasPrecedingItem && styles.noTopBorder,
|
item._showParentReplyLine && hasPrecedingItem && styles.noTopBorder,
|
||||||
|
styles.cursor,
|
||||||
]}
|
]}
|
||||||
moderation={item.moderation.content}>
|
moderation={item.moderation.content}>
|
||||||
<PostSandboxWarning />
|
<PostSandboxWarning />
|
||||||
|
@ -616,4 +617,8 @@ const styles = StyleSheet.create({
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
marginRight: 'auto',
|
marginRight: 'auto',
|
||||||
},
|
},
|
||||||
|
cursor: {
|
||||||
|
// @ts-ignore web only
|
||||||
|
cursor: 'pointer',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -304,6 +304,7 @@ const styles = StyleSheet.create({
|
||||||
paddingBottom: 5,
|
paddingBottom: 5,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
borderTopWidth: 1,
|
borderTopWidth: 1,
|
||||||
|
cursor: 'pointer',
|
||||||
},
|
},
|
||||||
layout: {
|
layout: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|
|
@ -343,6 +343,7 @@ const styles = StyleSheet.create({
|
||||||
borderTopWidth: 1,
|
borderTopWidth: 1,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
paddingRight: 15,
|
paddingRight: 15,
|
||||||
|
cursor: 'pointer',
|
||||||
},
|
},
|
||||||
outerSmallTop: {
|
outerSmallTop: {
|
||||||
borderTopWidth: 0,
|
borderTopWidth: 0,
|
||||||
|
|
|
@ -259,15 +259,21 @@ function onPressInner(
|
||||||
e?: Event,
|
e?: Event,
|
||||||
) {
|
) {
|
||||||
let shouldHandle = false
|
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) {
|
if (Platform.OS !== 'web' || !e) {
|
||||||
shouldHandle = e ? !e.defaultPrevented : true
|
shouldHandle = e ? !e.defaultPrevented : true
|
||||||
} else if (
|
} else if (
|
||||||
!e.defaultPrevented && // onPress prevented default
|
!e.defaultPrevented && // onPress prevented default
|
||||||
// @ts-ignore Web only -prf
|
(isLeftClick || isMiddleClick) && // ignore everything but left and middle clicks
|
||||||
!(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
|
|
||||||
// @ts-ignore Web only -prf
|
// @ts-ignore Web only -prf
|
||||||
[undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle "target=_blank" etc.
|
[undefined, null, '', 'self'].includes(e.currentTarget?.target) // let browser handle "target=_blank" etc.
|
||||||
) {
|
) {
|
||||||
|
@ -277,7 +283,7 @@ function onPressInner(
|
||||||
|
|
||||||
if (shouldHandle) {
|
if (shouldHandle) {
|
||||||
href = convertBskyAppUrlIfNeeded(href)
|
href = convertBskyAppUrlIfNeeded(href)
|
||||||
if (href.startsWith('http') || href.startsWith('mailto')) {
|
if (newTab || href.startsWith('http') || href.startsWith('mailto')) {
|
||||||
Linking.openURL(href)
|
Linking.openURL(href)
|
||||||
} else {
|
} else {
|
||||||
store.shell.closeModal() // close any active modals
|
store.shell.closeModal() // close any active modals
|
||||||
|
|
Loading…
Reference in New Issue