import { LinkPreviewType } from "@openchat/types" import { useRef } from "react" import…
- User
import { LinkPreviewType } from "@openchat/types" import { useRef } from "react" import { FlatList, Image, LayoutAnimation, TouchableOpacity, View, } from "react-native" import { AppColors } from "../../../app/app.colors" import { Icon } from "../../../ui-components/icon/icon.component" import { StyledText } from "../../../ui-components/styled-text/styled-text" import { useStyles } from "./link-input-preview.style"
export function LinkInputPreview({ links, linkIgnoreList, setLinkIgnoreList, }: { links: LinkPreviewType[] linkIgnoreList: string[] setLinkIgnoreList: (links: string[]) => void }) { // --------------------------------------------------------------------------- // variables // ---------------------------------------------------------------------------
const styles = useStyles() const flatListRef = useRef<FlatList>(null) const layoutAnimConfig = { duration: 300, update: { type: LayoutAnimation.Types.easeInEaseOut, }, delete: { duration: 100, type: LayoutAnimation.Types.easeInEaseOut, property: LayoutAnimation.Properties.opacity, }, }
// --------------------------------------------------------------------------- // functions // ---------------------------------------------------------------------------
async function deleteLink(link: LinkPreviewType) { setLinkIgnoreList([...linkIgnoreList, link.url]) }
// --------------------------------------------------------------------------- return ( <FlatList showsHorizontalScrollIndicator={false} ref={flatListRef} contentContainerStyle={[styles.scrollWrapper, { gap: 10 }]} horizontal={true} data={links} keyExtractor={(link, index) => link.url} renderItem={({ item: link, index }) => { return ( {link.photo.trim() !== "" && ( <Image resizeMode="cover" style={styles.photo} source={{ uri: link.photo }} /> )} {link.title} {link.description} <TouchableOpacity activeOpacity={0.9} style={styles.xHolder} onPress={() => { deleteLink(link) LayoutAnimation.configureNext(layoutAnimConfig) }} > ) }} /> ) } delete link not working
- Assistant