Skip to content

Commit 199cbdc

Browse files
Saadnajmitido64
andcommitted
Apply suggestions from code review
Co-authored-by: Tommy Nguyen <[email protected]>
1 parent 86d1a4b commit 199cbdc

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17161716
for (NSString *file in fileNames) {
17171717
NSURL *fileURL = [NSURL fileURLWithPath:file];
17181718
BOOL isDir = NO;
1719-
BOOL isValid = (![[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] || isDir) ? NO : YES;
1719+
BOOL isValid = [[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] && !isDir;
17201720
if (isValid) {
17211721

17221722
NSString *MIMETypeString = nil;
@@ -1736,14 +1736,6 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17361736
forKey:NSURLFileSizeKey
17371737
error:&fileSizeError];
17381738

1739-
NSNumber *width = nil;
1740-
NSNumber *height = nil;
1741-
if ([MIMETypeString hasPrefix:@"image/"]) {
1742-
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1743-
width = @(image.size.width);
1744-
height = @(image.size.height);
1745-
}
1746-
17471739
DataTransferItem transferItem = {
17481740
.name = fileURL.lastPathComponent.UTF8String,
17491741
.kind = "file",
@@ -1755,12 +1747,10 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17551747
transferItem.size = fileSizeValue.intValue;
17561748
}
17571749

1758-
if (width != nil) {
1759-
transferItem.width = width.intValue;
1760-
}
1761-
1762-
if (height != nil) {
1763-
transferItem.height = height.intValue;
1750+
if ([MIMETypeString hasPrefix:@"image/"]) {
1751+
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1752+
transferItem.width = static_cast<int>(image.size.width);
1753+
transferItem.height = static_cast<int>(image.size.height);
17641754
}
17651755

17661756
dataTransferItems.push_back(transferItem);
@@ -1777,9 +1767,9 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17771767
.kind = "image",
17781768
.type = MIMETypeString.UTF8String,
17791769
.uri = RCTDataURL(MIMETypeString, imageData).absoluteString.UTF8String,
1780-
.size = imageData.length,
1781-
.width = image.size.width,
1782-
.height = image.size.height,
1770+
.size = static_cast<int>(imageData.length),
1771+
.width = static_cast<int>(image.size.width),
1772+
.height = static_cast<int>(image.size.height),
17831773
};
17841774

17851775
dataTransferItems.push_back(transferItem);

packages/react-native/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ HostPlatformViewProps::HostPlatformViewProps(
7070
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
7171
? sourceProps.draggedTypes
7272
: convertRawProp(
73-
context,
74-
rawProps,
75-
"draggedTypes",
76-
sourceProps.draggedTypes,
77-
{}))
73+
context,
74+
rawProps,
75+
"draggedTypes",
76+
sourceProps.draggedTypes,
77+
{})),
7878
tooltip(
7979
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
8080
? sourceProps.tooltip

0 commit comments

Comments
 (0)