Skip to content

Commit

Permalink
Disable like/repost animations to see if theyre causing #135 (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee authored Feb 2, 2023
1 parent 1c48137 commit b14cf93
Showing 1 changed file with 64 additions and 26 deletions.
90 changes: 64 additions & 26 deletions src/view/com/util/PostCtrls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import {
Animated,
StyleProp,
StyleSheet,
TouchableOpacity,
Expand All @@ -9,10 +8,11 @@ import {
} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'
import {
TriggerableAnimated,
TriggerableAnimatedRef,
} from './anim/TriggerableAnimated'
// DISABLED see #135
// import {
// TriggerableAnimated,
// TriggerableAnimatedRef,
// } from './anim/TriggerableAnimated'
import {Text} from './text/Text'
import {PostDropdownBtn} from './forms/DropdownButton'
import {
Expand Down Expand Up @@ -44,6 +44,8 @@ interface PostCtrlsOpts {

const HITSLOP = {top: 5, left: 5, bottom: 5, right: 5}

// DISABLED see #135
/*
function ctrlAnimStart(interp: Animated.Value) {
return Animated.sequence([
Animated.timing(interp, {
Expand Down Expand Up @@ -76,6 +78,7 @@ function ctrlAnimStyle(interp: Animated.Value) {
}),
}
}
*/

export function PostCtrls(opts: PostCtrlsOpts) {
const theme = useTheme()
Expand All @@ -87,19 +90,25 @@ export function PostCtrls(opts: PostCtrlsOpts) {
)
const [repostMod, setRepostMod] = React.useState<number>(0)
const [likeMod, setLikeMod] = React.useState<number>(0)
const repostRef = React.useRef<TriggerableAnimatedRef | null>(null)
const likeRef = React.useRef<TriggerableAnimatedRef | null>(null)
// DISABLED see #135
// const repostRef = React.useRef<TriggerableAnimatedRef | null>(null)
// const likeRef = React.useRef<TriggerableAnimatedRef | null>(null)
const onPressToggleRepostWrapper = () => {
if (!opts.isReposted) {
ReactNativeHapticFeedback.trigger('impactMedium')
setRepostMod(1)
repostRef.current?.trigger(
{start: ctrlAnimStart, style: ctrlAnimStyle},
async () => {
await opts.onPressToggleRepost().catch(_e => undefined)
setRepostMod(0)
},
)
opts
.onPressToggleRepost()
.catch(_e => undefined)
.then(() => setRepostMod(0))
// DISABLED see #135
// repostRef.current?.trigger(
// {start: ctrlAnimStart, style: ctrlAnimStyle},
// async () => {
// await opts.onPressToggleRepost().catch(_e => undefined)
// setRepostMod(0)
// },
// )
} else {
setRepostMod(-1)
opts
Expand All @@ -112,13 +121,18 @@ export function PostCtrls(opts: PostCtrlsOpts) {
if (!opts.isUpvoted) {
ReactNativeHapticFeedback.trigger('impactMedium')
setLikeMod(1)
likeRef.current?.trigger(
{start: ctrlAnimStart, style: ctrlAnimStyle},
async () => {
await opts.onPressToggleUpvote().catch(_e => undefined)
setLikeMod(0)
},
)
opts
.onPressToggleUpvote()
.catch(_e => undefined)
.then(() => setLikeMod(0))
// DISABLED see #135
// likeRef.current?.trigger(
// {start: ctrlAnimStart, style: ctrlAnimStyle},
// async () => {
// await opts.onPressToggleUpvote().catch(_e => undefined)
// setLikeMod(0)
// },
// )
} else {
setLikeMod(-1)
opts
Expand Down Expand Up @@ -152,7 +166,17 @@ export function PostCtrls(opts: PostCtrlsOpts) {
hitSlop={HITSLOP}
onPress={onPressToggleRepostWrapper}
style={styles.ctrl}>
<TriggerableAnimated ref={repostRef}>
<RepostIcon
style={
opts.isReposted || repostMod > 0
? styles.ctrlIconReposted
: defaultCtrlColor
}
strokeWidth={2.4}
size={opts.big ? 24 : 20}
/>
{
undefined /*DISABLED see #135 <TriggerableAnimated ref={repostRef}>
<RepostIcon
style={
opts.isReposted || repostMod > 0
Expand All @@ -162,8 +186,8 @@ export function PostCtrls(opts: PostCtrlsOpts) {
strokeWidth={2.4}
size={opts.big ? 24 : 20}
/>
</TriggerableAnimated>

</TriggerableAnimated>*/
}
{typeof opts.repostCount !== 'undefined' ? (
<Text
style={
Expand All @@ -181,7 +205,20 @@ export function PostCtrls(opts: PostCtrlsOpts) {
style={styles.ctrl}
hitSlop={HITSLOP}
onPress={onPressToggleUpvoteWrapper}>
<TriggerableAnimated ref={likeRef}>
{opts.isUpvoted || likeMod > 0 ? (
<HeartIconSolid
style={[styles.ctrlIconUpvoted]}
size={opts.big ? 22 : 16}
/>
) : (
<HeartIcon
style={[defaultCtrlColor, opts.big ? styles.mt1 : undefined]}
strokeWidth={3}
size={opts.big ? 20 : 16}
/>
)}
{
undefined /*DISABLED see #135 <TriggerableAnimated ref={likeRef}>
{opts.isUpvoted || likeMod > 0 ? (
<HeartIconSolid
style={[styles.ctrlIconUpvoted]}
Expand All @@ -194,7 +231,8 @@ export function PostCtrls(opts: PostCtrlsOpts) {
size={opts.big ? 20 : 16}
/>
)}
</TriggerableAnimated>
</TriggerableAnimated>*/
}
{typeof opts.upvoteCount !== 'undefined' ? (
<Text
style={
Expand Down

0 comments on commit b14cf93

Please sign in to comment.