Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions ios/gutenberg/MediaPickAndUploadCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MediaPickAndUploadCoordinator: NSObject, UIImagePickerControllerDelegate,
}
do {
try data.write(to: url)
mediaCallback(mediaID, url.absoluteString)
mediaCallback(mediaID.hashValue, url.absoluteString)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was reading this:
https://developer.apple.com/documentation/swift/hashable/1540917-hashvalue

Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution

Does it have any implications then, for example if you're uploading something and then close the app and open it again?

let progress = Progress(parent: nil, userInfo: [ProgressUserInfoKey.mediaID: mediaID, ProgressUserInfoKey.mediaURL: url])
progress.totalUnitCount = 100

Expand All @@ -63,10 +63,10 @@ class MediaPickAndUploadCoordinator: NSObject, UIImagePickerControllerDelegate,
progress.completedUnitCount += 1

if progress.fractionCompleted < 1 {
gutenberg.mediaUploadUpdate(id: mediaID, state: .uploading, progress: Float(progress.fractionCompleted), url: nil, serverID: nil)
gutenberg.mediaUploadUpdate(id: mediaID.hashValue, state: .uploading, progress: Float(progress.fractionCompleted), url: nil, serverID: nil)
} else if progress.fractionCompleted >= 1 {
timer.invalidate()
gutenberg.mediaUploadUpdate(id: mediaID, state: .succeeded, progress: 1, url: mediaURL, serverID: 124)
gutenberg.mediaUploadUpdate(id: mediaID.hashValue, state: .succeeded, progress: 1, url: mediaURL, serverID: 124)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion react-native-gutenberg-bridge/ios/Gutenberg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class Gutenberg: NSObject {
bridgeModule.sendEvent(withName: EventName.updateHtml, body: [ "html": html ])
}

public func mediaUploadUpdate(id: String, state: MediaUploadState, progress: Float, url: URL?, serverID: Int?) {
public func mediaUploadUpdate(id: Int, state: MediaUploadState, progress: Float, url: URL?, serverID: Int?) {
var data: [String: Any] = ["mediaId": id, "state": state.rawValue, "progress": progress];
if let url = url {
data["mediaUrl"] = url.absoluteString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public typealias MediaPickerDidPickMediaCallback = (_ id: Int?, _ url: String?) -> Void
public typealias MediaPickerDidPickMediaToUploadCallback = (_ id: String?, _ url: String?) -> Void
public typealias MediaPickerDidPickMediaToUploadCallback = (_ id: Int?, _ url: String?) -> Void

public protocol GutenbergBridgeDelegate: class {
/// Tells the delegate that Gutenberg had returned the requested HTML content.
Expand Down