Skip to content

Commit

Permalink
Merge pull request #79 from hhru/MOB-38596
Browse files Browse the repository at this point in the history
MOB-38596: Исправить загрузку картинок
  • Loading branch information
VDA22 authored May 16, 2024
2 parents 949fce8 + 920562d commit 33a3eaa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,18 @@ final class DefaultImageRenderProvider: ImageRenderProvider {
return .value([])
}

let promises = scales.map { scale in
renderImages(of: file, nodes: nodes, format: format, scale: scale, useAbsoluteBounds: useAbsoluteBounds)
.map { imageURLs in
(scale: scale, imageURLs: imageURLs)
}
}
let promises = scales
.map { scale in
nodes
.chunked(size: 100)
.map { nodesPars in
renderImages(of: file, nodes: nodesPars, format: format, scale: scale, useAbsoluteBounds: useAbsoluteBounds)
.map { imageURLs in
(scale: scale, imageURLs: imageURLs)
}
}
}
.flatMap { $0 }

return firstly {
when(fulfilled: promises)
Expand Down
10 changes: 10 additions & 0 deletions Sources/FigmaGenTools/Extensions/Array+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

extension Array {

public func chunked(size: Int) -> [[Element]] {
stride(from: 0, to: count, by: size).map {
Array(self[$0 ..< Swift.min($0 + size, count)])
}
}
}

0 comments on commit 33a3eaa

Please sign in to comment.