Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Tommy Nguyen <[email protected]>
  • Loading branch information
Saadnajmi and tido64 committed Oct 3, 2025
commit 9a6095c35d280297f4893fe8bb10cb709aea2092
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
for (NSString *file in fileNames) {
NSURL *fileURL = [NSURL fileURLWithPath:file];
BOOL isDir = NO;
BOOL isValid = (![[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] || isDir) ? NO : YES;
BOOL isValid = [[NSFileManager defaultManager] fileExistsAtPath:fileURL.path isDirectory:&isDir] && !isDir;
if (isValid) {

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

NSNumber *width = nil;
NSNumber *height = nil;
if ([MIMETypeString hasPrefix:@"image/"]) {
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
width = @(image.size.width);
height = @(image.size.height);
}

DataTransferItem transferItem = {
.name = fileURL.lastPathComponent.UTF8String,
.kind = "file",
Expand All @@ -1746,12 +1738,10 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
transferItem.size = fileSizeValue.intValue;
}

if (width != nil) {
transferItem.width = width.intValue;
}

if (height != nil) {
transferItem.height = height.intValue;
if ([MIMETypeString hasPrefix:@"image/"]) {
NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
transferItem.width = static_cast<int>(image.size.width);
transferItem.height = static_cast<int>(image.size.height);
}

dataTransferItems.push_back(transferItem);
Expand All @@ -1768,9 +1758,9 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
.kind = "image",
.type = MIMETypeString.UTF8String,
.uri = RCTDataURL(MIMETypeString, imageData).absoluteString.UTF8String,
.size = imageData.length,
.width = image.size.width,
.height = image.size.height,
.size = static_cast<int>(imageData.length),
.width = static_cast<int>(image.size.width),
.height = static_cast<int>(image.size.height),
};

dataTransferItems.push_back(transferItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ HostPlatformViewProps::HostPlatformViewProps(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.draggedTypes
: convertRawProp(
context,
rawProps,
"draggedTypes",
sourceProps.draggedTypes,
{})) {};
context,
rawProps,
"draggedTypes",
sourceProps.draggedTypes,
{})) {};

#define VIEW_EVENT_CASE_MACOS(eventType) \
case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \
Expand Down
Loading