-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Opened offline attachment directed to conversation page on online #49832
base: main
Are you sure you want to change the base?
Fix Opened offline attachment directed to conversation page on online #49832
Conversation
…tachment replaced / deleted
… index is similar
…x/48173-dismiss-when-no-attachment-with-same-page-index
…x/48173-dismiss-when-no-attachment-with-same-page-index
Co-authored-by: Abdelhafidh Belalia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+Run prettier
let initialPage = targetAttachments.findIndex(compareImage); | ||
const prevInitialPage = attachments.findIndex(compareImage); | ||
|
||
// If no matching attachment is found in targetAttachments but found in attachments, update initialPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is explaining the what not the why. Let's remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
// Dismiss the modal when deleting an attachment during its display in preview. | ||
if (initialPage === -1 && attachments.find(compareImage)) { | ||
// If no matching attachment with the same index, dismiss the modal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
let initialPage = targetAttachments.findIndex(compareImage); | ||
const prevInitialPage = attachments.findIndex(compareImage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let initialPage = targetAttachments.findIndex(compareImage); | |
const prevInitialPage = attachments.findIndex(compareImage); | |
let attachmentIndex = targetAttachments.findIndex(compareImage); | |
const prevAttachmentIndex = attachments.findIndex(compareImage); |
I feel that this naming is more correct. findIndex
returns an index and not a page. The index is used as the page id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const prevInitialPage = attachments.findIndex(compareImage); | ||
|
||
// If no matching attachment is found in targetAttachments but found in attachments, update initialPage | ||
if (initialPage === -1 && prevInitialPage !== -1 && targetAttachments[prevInitialPage]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid comparing with -1 and instead just access the attachment array directly
if (!targetAttachments[attachmentIndex] && targetAttachments[prevAttachmentIndex])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…x/48173-dismiss-when-no-attachment-with-same-page-index
let attachmentIndex = targetAttachments.findIndex(compareImage); | ||
const prevAttachmentIndex = attachments.findIndex(compareImage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB. Another naming clarity. targetAttachments
is confusing.
- targetAttachments -> newAttachments
- attachmentIndex -> newIndex
- prevAttachmentIndex -> index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemweb-chrome.moviOS: Nativeios.moviOS: mWeb Safarimweb-safari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@wildan-m Can you check why on native the attachment changes after getting online? ios.movandroid.mov |
…x/48173-dismiss-when-no-attachment-with-same-page-index
that's pretty weird. @s77rt do you know how to make metro keep logging the log after re-connect? |
@wildan-m Try use Xcode or Android Studio.
|
let attachmentIndex = targetAttachments.findIndex(compareImage); | ||
const prevAttachmentIndex = attachments.findIndex(compareImage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do same refactor on the names on this file too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@wildan-m Can you clarify how |
@s77rt it appears that's an upstream issue, I'll try to reproduce it with simple example. If that's an upstream issue, should we fix it with this PR?
It only remounts if we encounter this condition, I think that will not hurt the performance that much if (!newAttachments[newIndex] && newAttachments[index]) { |
…x/48173-dismiss-when-no-attachment-with-same-page-index
@s77rt I've created this simple reproduction step, even without scrolling from reanimated, the pager view itself can't properly work if we replace the pager items without re-mounting. Kapture.2024-10-01.at.10.31.56.mp4I think we don't need to report the issue as there are similar issues open. Minimum reproducible codeimport React from 'react';
import { useState } from 'react';
import { Button, SafeAreaView, Text, View, StyleSheet } from 'react-native';
import PagerView from 'react-native-pager-view';
const ids = ['1', '2', '3'];
function getNewArray() {
const newArray = [...ids];
newArray[2] = Math.random().toString(36).substring(7); // Generate a random string
return newArray;
}
export const BasicPagerViewExample = () => {
const [pagesContent, setPagesContent] = useState<string[]>(getNewArray());
const [page, setPage] = useState<number>(2);
console.log(pagesContent);
return (
<SafeAreaView style={{ flex: 1 }}>
<Text style={{ textAlign: 'center' }}>{pagesContent.length}</Text>
<PagerView orientation="horizontal" style={{ flex: 1, backgroundColor: 'yellow' }} initialPage={page}
onPageSelected={(e) => {
console.log('onPageSelected ~ e.nativeEvent.position:', e.nativeEvent.position);
}}
>
{pagesContent.map((content) => (
<View key={content} style={{ flex: 1,backgroundColor: 'green' }}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' , backgroundColor:'red'}}>
<Text style={{ fontSize: 30 }}>{content}</Text>
</View>
</View>
))}
</PagerView>
<Button
title={'Replace third page content'}
onPress={() => {
setPagesContent(getNewArray());
setPage(2);
}}
/>
</SafeAreaView>
);
};
export default BasicPagerViewExample
|
Details
Fix offline attachment opening directly to online conversation page. New dismissal behavior confirmed here: #48173 (comment)
Fixed Issues
$ #48173
PROPOSAL: #48173 (comment) (Alternative 3)
Tests
Offline tests
Same as test
QA Steps
Same as test
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Kapture.2024-09-27.at.14.02.17.mp4
Android: mWeb Chrome
Kapture.2024-09-27.at.14.05.10.mp4
iOS: Native
Kapture.2024-09-27.at.11.02.28.mp4
iOS: mWeb Safari
Kapture.2024-09-27.at.13.31.57.mp4
MacOS: Chrome / Safari
Kapture.2024-09-27.at.10.41.52.mp4
MacOS: Desktop
Kapture.2024-09-27.at.14.06.18.mp4