Skip to content

Commit

Permalink
Merge pull request #49908 from nkdengineer/fix/48697
Browse files Browse the repository at this point in the history
fix: Chat blinks when txt attachment is uploaded
  • Loading branch information
MonilBhavsar authored Oct 14, 2024
2 parents 7867100 + 8507bb3 commit 4fffdd5
Showing 1 changed file with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import AttachmentView from '@components/Attachments/AttachmentView';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext';
Expand All @@ -13,27 +12,20 @@ import * as ReportUtils from '@libs/ReportUtils';
import * as Download from '@userActions/Download';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Download as OnyxDownload} from '@src/types/onyx';
import type AnchorForAttachmentsOnlyProps from './types';

type BaseAnchorForAttachmentsOnlyOnyxProps = {
/** If a file download is happening */
download: OnyxEntry<OnyxDownload>;
};

type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps &
BaseAnchorForAttachmentsOnlyOnyxProps & {
/** Press in handler for the link */
onPressIn?: () => void;
type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & {
/** Press in handler for the link */
onPressIn?: () => void;

/** Press out handler for the link */
onPressOut?: () => void;
};
/** Press out handler for the link */
onPressOut?: () => void;
};

function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) {
function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) {
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source);
const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];

const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`);
const {isOffline} = useNetwork();
const styles = useThemeStyles();

Expand Down Expand Up @@ -78,11 +70,4 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow

BaseAnchorForAttachmentsOnly.displayName = 'BaseAnchorForAttachmentsOnly';

export default withOnyx<BaseAnchorForAttachmentsOnlyProps, BaseAnchorForAttachmentsOnlyOnyxProps>({
download: {
key: ({source}) => {
const sourceID = (source?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];
return `${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`;
},
},
})(BaseAnchorForAttachmentsOnly);
export default BaseAnchorForAttachmentsOnly;

0 comments on commit 4fffdd5

Please sign in to comment.