Skip to content

Commit

Permalink
Merge pull request #12783 from wordpress-mobile/gutenberg/hotfix-1.15.2
Browse files Browse the repository at this point in the history
[Gutenberg] Hotfix 1.15.2
  • Loading branch information
mchowning authored Oct 29, 2019
2 parents 85d356a + 9dd468c commit b30ac20
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ target 'WordPress' do
## Gutenberg (React Native)
## =====================
##
gutenberg :tag => 'v1.15.0'
gutenberg :tag => 'v1.15.2'

## Third party libraries
## =====================
Expand Down
122 changes: 61 additions & 61 deletions Podfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Block editor: Add Link Target (Open in new tab) to Image Block settings.
* Block editor: DarkMode improvements.
* Block editor: New block "Media & Text".
* Block Editor: Fix issue where the block inserter layout wasn't correct after device rotation.
* Dark Mode: General improvements
* Stats: each Insight stat now loads independently.
* Stats: added ability to customize Insights.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class GutenbergMediaInserterHelper: NSObject {

func insertFromSiteMediaLibrary(media: [Media], callback: @escaping MediaPickerDidPickMediaCallback) {
let formattedMedia = media.map { item in
return (item.mediaID?.int32Value, item.remoteURL, item.mediaTypeString)
return MediaInfo(id: item.mediaID?.int32Value, url: item.remoteURL, type: item.mediaTypeString)
}
callback(formattedMedia)
}

func insertFromDevice(assets: [PHAsset], callback: @escaping MediaPickerDidPickMediaCallback) {
var mediaCollection: [(Int32?, String?, String?)] = []
var mediaCollection: [MediaInfo] = []
let group = DispatchGroup()
assets.forEach { asset in
group.enter()
Expand Down Expand Up @@ -68,16 +68,16 @@ class GutenbergMediaInserterHelper: NSObject {
// Getting a quick thumbnail of the asset to display while the image is being exported and uploaded.
PHImageManager.default().requestImage(for: asset, targetSize: asset.pixelSize(), contentMode: .default, options: options) { (image, info) in
guard let thumbImage = image, let resizedImage = thumbImage.resizedImage(asset.pixelSize(), interpolationQuality: CGInterpolationQuality.low) else {
callback([(mediaUploadID, nil, media.mediaTypeString)])
callback([MediaInfo(id: mediaUploadID, url: nil, type: media.mediaTypeString)])
return
}
let filePath = NSTemporaryDirectory() + "\(mediaUploadID).jpg"
let url = URL(fileURLWithPath: filePath)
do {
try resizedImage.writeJPEGToURL(url)
callback([(mediaUploadID, url.absoluteString, media.mediaTypeString)])
callback([MediaInfo(id: mediaUploadID, url: url.absoluteString, type: media.mediaTypeString)])
} catch {
callback([(mediaUploadID, nil, media.mediaTypeString)])
callback([MediaInfo(id: mediaUploadID, url: nil, type: media.mediaTypeString)])
return
}
}
Expand All @@ -87,7 +87,7 @@ class GutenbergMediaInserterHelper: NSObject {
func insertFromDevice(url: URL, callback: @escaping MediaPickerDidPickMediaCallback) {
let media = insert(exportableAsset: url as NSURL, source: .otherApps)
let mediaUploadID = media.gutenbergUploadID
callback([(mediaUploadID, url.absoluteString, media.mediaTypeString)])
callback([MediaInfo(id: mediaUploadID, url: url.absoluteString, type: media.mediaTypeString)])
}

func syncUploads() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class GutenbergViewController: UIViewController, PostEditor {
}
self.mediaInserterHelper.insertFromDevice(assets: phAsset, callback: { media in
guard let media = media,
let (id, url, _) = media.first,
let mediaID = id,
let mediaURLString = url,
let mediaInfo = media.first,
let mediaID = mediaInfo.id,
let mediaURLString = mediaInfo.url,
let mediaURL = URL(string: mediaURLString) else {
return
}
Expand Down Expand Up @@ -421,8 +421,10 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
})
}

func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaPickerDidPickMediaCallback) {
mediaInserterHelper.insertFromDevice(url: url, callback: callback)
func gutenbergDidRequestImport(from url: URL, with callback: @escaping MediaImportCallback) {
mediaInserterHelper.insertFromDevice(url: url, callback: { media in
callback(media?.first)
})
}

func gutenbergDidRequestMediaUploadSync() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class GutenbergImgUploadProcessor: Processor {

func process(_ text: String) -> String {
var result = imgPostMediaUploadProcessor.process(text)
result = result.replacingOccurrences(of: "wp:image {\"id\":\(String(mediaUploadID))}", with: "wp:image {\"id\":\(String(serverMediaID))}")
result = result.replacingOccurrences(of: "wp:image {\"id\":\(String(mediaUploadID))", with: "wp:image {\"id\":\(String(serverMediaID))")
result = result.replacingOccurrences(of: "wp:media-text {\"mediaId\":\(String(mediaUploadID))", with: "wp:media-text {\"mediaId\":\(String(serverMediaID))")
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class GutenbergVideoUploadProcessor: Processor {

func process(_ text: String) -> String {
var result = videoHtmlProcessor.process(text)
result = result.replacingOccurrences(of: "wp:video {\"id\":\(String(mediaUploadID))}", with: "wp:video {\"id\":\(String(serverMediaID))}")
result = result.replacingOccurrences(of: "wp:video {\"id\":\(String(mediaUploadID))", with: "wp:video {\"id\":\(String(serverMediaID))")
result = result.replacingOccurrences(of: "wp:media-text {\"mediaId\":\(String(mediaUploadID))", with: "wp:media-text {\"mediaId\":\(String(serverMediaID))")
return result
}

Expand Down

0 comments on commit b30ac20

Please sign in to comment.