* Handle FileWillBeDownloaded plugin hook rejections - Add WebSocket handler for file_download_rejected events - Show rejected files as file cards instead of broken thumbnails - Display plugin rejection message in snackbar - Store rejection reason in EphemeralStore for later retrieval - Re-render file components when rejection events arrive - Remove blurred preview to prevent visual blink on rejection * chore: lint * chore: lint and test * fix: removed event from useEffect
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useCallback} from 'react';
|
|
import {Pressable} from 'react-native-gesture-handler';
|
|
import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
|
|
|
|
import type {StyleProp, ViewStyle} from 'react-native';
|
|
|
|
type Props = {
|
|
children: React.ReactNode;
|
|
onPress: () => void;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
export default function PressableOpacity({children, onPress, style}: Props) {
|
|
const cancelOpacity = useSharedValue(1);
|
|
|
|
const cancelAnimatedStyle = useAnimatedStyle(() => {
|
|
return {
|
|
opacity: cancelOpacity.value,
|
|
};
|
|
});
|
|
|
|
const cancelPressIn = useCallback(() => {
|
|
cancelOpacity.value = withTiming(0.5, {duration: 100});
|
|
}, [cancelOpacity]);
|
|
|
|
const cancelPressOut = useCallback(() => {
|
|
cancelOpacity.value = withTiming(1, {duration: 300});
|
|
}, [cancelOpacity]);
|
|
|
|
return (
|
|
<Pressable
|
|
onPressIn={cancelPressIn}
|
|
onPressOut={cancelPressOut}
|
|
onPress={onPress}
|
|
style={[style]}
|
|
>
|
|
<Animated.View style={cancelAnimatedStyle}>
|
|
{children}
|
|
</Animated.View>
|
|
</Pressable>
|
|
);
|
|
}
|