From a419ccce273397e79855af892f3e57f81f17e458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Mon, 22 May 2023 15:03:05 +0200 Subject: [PATCH] feat(all): Add modificationTimestamp field (#493) * feat(android): Rename modified node field to more explicit name * feat(ios): Return modificationDate in ios * docs: Add modification date in ts, docs and examples --- FabricExample/js/CameraRollExample.js | 1 + README.md | 1 + .../com/reactnativecommunity/cameraroll/CameraRollModule.java | 2 +- example/js/CameraRollExample.js | 1 + ios/RNCCameraRoll.mm | 3 +++ src/CameraRoll.ts | 1 + src/NativeCameraRollModule.ts | 1 + 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/FabricExample/js/CameraRollExample.js b/FabricExample/js/CameraRollExample.js index fb68e0b..e332644 100644 --- a/FabricExample/js/CameraRollExample.js +++ b/FabricExample/js/CameraRollExample.js @@ -112,6 +112,7 @@ export default class CameraRollExample extends React.Component { {locationStr} {asset.node.group_name} {new Date(asset.node.timestamp * 1000).toString()} + {new Date(asset.node.modificationTimestamp * 1000).toString()} diff --git a/README.md b/README.md index bd7a950..cd8a419 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,7 @@ Returns a Promise which when resolved will be of the following shape: * `playableDuration`: {number | null} : Only set for videos if the `include` parameter contains `playableDuration`. Will be null for images. * `orientation`: {number | null} : Only set for images if the `include` parameter contains `orientation`. **Android only** * `timestamp`: {number} + * `modificationTimestamp`: {number} * `location`: {object | null} : Only set if the `include` parameter contains `location`. An object with the following shape: * `latitude`: {number} * `longitude`: {number} diff --git a/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java b/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java index 332f9b8..7dff0ca 100644 --- a/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java +++ b/android/src/main/java/com/reactnativecommunity/cameraroll/CameraRollModule.java @@ -622,7 +622,7 @@ public class CameraRollModule extends NativeCameraRollModuleSpec { dateTaken = media.getLong(dateAddedIndex) * 1000; } node.putDouble("timestamp", dateTaken / 1000d); - node.putDouble("modified", media.getLong(dateModifiedIndex)); + node.putDouble("modificationTimestamp", media.getLong(dateModifiedIndex)); } /** diff --git a/example/js/CameraRollExample.js b/example/js/CameraRollExample.js index 02a53b7..cb42790 100644 --- a/example/js/CameraRollExample.js +++ b/example/js/CameraRollExample.js @@ -112,6 +112,7 @@ export default class CameraRollExample extends React.Component { {locationStr} {asset.node.group_name} {new Date(asset.node.timestamp * 1000).toString()} + {new Date(asset.node.modificationTimestamp * 1000).toString()} diff --git a/ios/RNCCameraRoll.mm b/ios/RNCCameraRoll.mm index baa2b15..65aa2c0 100644 --- a/ios/RNCCameraRoll.mm +++ b/ios/RNCCameraRoll.mm @@ -446,6 +446,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params : [NSNull null]) }, @"timestamp": @(asset.creationDate.timeIntervalSince1970), + @"modificationTimestamp": @(asset.modificationDate.timeIntervalSince1970), @"location": (includeLocation && loc ? @{ @"latitude": @(loc.coordinate.latitude), @"longitude": @(loc.coordinate.longitude), @@ -598,6 +599,7 @@ RCT_EXPORT_METHOD(getPhotoByInternalID:(NSString *)internalId @"fileSize": @(fileSize) }, @"timestamp": @(asset.creationDate.timeIntervalSince1970), + @"modificationTimestamp": @(asset.modificationDate.timeIntervalSince1970), @"location": (loc ? @{ @"latitude": @(loc.coordinate.latitude), @"longitude": @(loc.coordinate.longitude), @@ -639,6 +641,7 @@ RCT_EXPORT_METHOD(getPhotoByInternalID:(NSString *)internalId @"fileSize": fileSize }, @"timestamp": @(asset.creationDate.timeIntervalSince1970), + @"modificationTimestamp": @(asset.modificationDate.timeIntervalSince1970), @"location": (loc ? @{ @"latitude": @(loc.coordinate.latitude), @"longitude": @(loc.coordinate.longitude), diff --git a/src/CameraRoll.ts b/src/CameraRoll.ts index 14765d7..b7ffa53 100644 --- a/src/CameraRoll.ts +++ b/src/CameraRoll.ts @@ -113,6 +113,7 @@ export type PhotoIdentifier = { orientation: number | null; }; timestamp: number; + modificationTimestamp: number; location: { latitude?: number; longitude?: number; diff --git a/src/NativeCameraRollModule.ts b/src/NativeCameraRollModule.ts index 1604426..ec436f8 100644 --- a/src/NativeCameraRollModule.ts +++ b/src/NativeCameraRollModule.ts @@ -24,6 +24,7 @@ type PhotoIdentifier = { orientation: number | null; }; timestamp: number; + modificationTimestamp: number; location: { latitude?: number; longitude?: number;