Skip to content

Commit 9a6095c

Browse files
Saadnajmitido64
andcommitted
Apply suggestions from code review
Co-authored-by: Tommy Nguyen <[email protected]>
1 parent 2851aac commit 9a6095c

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
@@ -1707,7 +1707,7 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17071707
for (NSString *file in fileNames) {
17081708
NSURL *fileURL = [NSURL fileURLWithPath:file];
17091709
BOOL isDir = NO;
1710-
BOOL isValid = (![[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] || isDir) ? NO : YES;
1710+
BOOL isValid = [[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] && !isDir;
17111711
if (isValid) {
17121712

17131713
NSString *MIMETypeString = nil;
@@ -1727,14 +1727,6 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17271727
forKey:NSURLFileSizeKey
17281728
error:&fileSizeError];
17291729

1730-
NSNumber *width = nil;
1731-
NSNumber *height = nil;
1732-
if ([MIMETypeString hasPrefix:@"image/"]) {
1733-
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1734-
width = @(image.size.width);
1735-
height = @(image.size.height);
1736-
}
1737-
17381730
DataTransferItem transferItem = {
17391731
.name = fileURL.lastPathComponent.UTF8String,
17401732
.kind = "file",
@@ -1746,12 +1738,10 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17461738
transferItem.size = fileSizeValue.intValue;
17471739
}
17481740

1749-
if (width != nil) {
1750-
transferItem.width = width.intValue;
1751-
}
1752-
1753-
if (height != nil) {
1754-
transferItem.height = height.intValue;
1741+
if ([MIMETypeString hasPrefix:@"image/"]) {
1742+
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1743+
transferItem.width = static_cast<int>(image.size.width);
1744+
transferItem.height = static_cast<int>(image.size.height);
17551745
}
17561746

17571747
dataTransferItems.push_back(transferItem);
@@ -1768,9 +1758,9 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17681758
.kind = "image",
17691759
.type = MIMETypeString.UTF8String,
17701760
.uri = RCTDataURL(MIMETypeString, imageData).absoluteString.UTF8String,
1771-
.size = imageData.length,
1772-
.width = image.size.width,
1773-
.height = image.size.height,
1761+
.size = static_cast<int>(imageData.length),
1762+
.width = static_cast<int>(image.size.width),
1763+
.height = static_cast<int>(image.size.height),
17741764
};
17751765

17761766
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

7979
#define VIEW_EVENT_CASE_MACOS(eventType) \
8080
case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \

0 commit comments

Comments
 (0)