mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-04 08:27:30 +01:00
Retain original ordering of media URLs (#503)
Co-authored-by: Greg <greg@cromulentlabs.com>
This commit is contained in:
parent
a8b147255b
commit
59ef1b2909
@ -17,6 +17,11 @@ public class QuickLook: ObservableObject {
|
||||
isPreparing = true
|
||||
}
|
||||
do {
|
||||
var order = 0
|
||||
let pathOrderMap = urls.reduce(into: [String: Int]()) { result, url in
|
||||
result[url.lastPathComponent] = order
|
||||
order += 1
|
||||
}
|
||||
let paths: [URL] = try await withThrowingTaskGroup(of: URL.self, body: { group in
|
||||
var paths: [URL] = []
|
||||
for url in urls {
|
||||
@ -27,7 +32,9 @@ public class QuickLook: ObservableObject {
|
||||
for try await path in group {
|
||||
paths.append(path)
|
||||
}
|
||||
return paths
|
||||
return paths.sorted { url1, url2 in
|
||||
return pathOrderMap[url1.lastPathComponent] ?? 0 < pathOrderMap[url2.lastPathComponent] ?? 0
|
||||
}
|
||||
})
|
||||
withTransaction(transaction) {
|
||||
self.urls = paths
|
||||
|
Loading…
x
Reference in New Issue
Block a user