mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-03-11 05:19:13 +00:00
YAY FIXED
This commit is contained in:
@@ -53,51 +53,41 @@ class EmojiHoarder: ObservableObject {
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func downloadAllStickers() async {
|
func downloadAllStickers() async {
|
||||||
|
let start: Date = .now
|
||||||
|
|
||||||
downloadedEmojisArr = []
|
downloadedEmojisArr = []
|
||||||
|
|
||||||
let cores = ProcessInfo.processInfo.processorCount-1
|
let cores = ProcessInfo.processInfo.processorCount-1
|
||||||
var indiciesSplit: [Range<Int>] = []
|
var ranges: [Range<Int>] = []
|
||||||
for i in 0..<cores {
|
for i in 0..<cores {
|
||||||
let onething = emojis.count/cores
|
let onething = emojis.count/cores
|
||||||
indiciesSplit.append(onething*i..<onething + (onething*i))
|
ranges.append(onething*i..<onething + (onething*i))
|
||||||
if i == (0..<cores).last {
|
if i == (0..<cores).last {
|
||||||
let last = indiciesSplit.last!
|
let last = ranges.last!
|
||||||
indiciesSplit.append(onething*i..<(onething + (onething*i)+emojis.count-last.upperBound))
|
ranges.removeLast()
|
||||||
}
|
ranges.append(onething*i..<(onething + (onething*i)+emojis.count-last.upperBound))
|
||||||
}
|
|
||||||
print(indiciesSplit)
|
|
||||||
|
|
||||||
var t: Int = 0
|
|
||||||
for split in indiciesSplit {
|
|
||||||
for thing in split {
|
|
||||||
t+=1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print(t)
|
await withTaskGroup { group in
|
||||||
print()
|
for range in ranges {
|
||||||
|
group.addTask {
|
||||||
// let indicies = emojis.indices.split(separator: indiciesSplit)
|
for i in range {
|
||||||
|
await MainActor.run { self.downloadedEmojisArr.append(self.emojis[i].name) }
|
||||||
// await withTaskGroup { group in
|
guard !self.downloadedEmojis.contains(await self.emojis[i].name) else { continue }
|
||||||
// for indicy in indicies {
|
Task { await self.download(emoji: self.emojis[i], skipStoreIndex: true) }
|
||||||
// group.addTask {
|
await MainActor.run { self.downloadedEmojis.insert(self.emojis[i].name) }
|
||||||
// for i in indicy {
|
if i == self.emojis.count {
|
||||||
// print(i)
|
Task { @MainActor in
|
||||||
// }
|
self.storeDownloadedIndexes()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
for emoji in emojis {
|
}
|
||||||
downloadedEmojisArr.append(emoji.name)
|
}
|
||||||
guard !downloadedEmojis.contains(emoji.name) else { continue }
|
|
||||||
await download(emoji: emoji, skipStoreIndex: true)
|
|
||||||
downloadedEmojis.insert(emoji.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
|
print(Date.now.timeIntervalSince(start))
|
||||||
self.storeDownloadedIndexes()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section("Stats") {
|
||||||
Text("\(hoarder.emojis.count) total Emoji")
|
Text("\(hoarder.emojis.count) total Emoji")
|
||||||
Text("\(hoarder.downloadedEmojis.count) downloaded Emoji")
|
Text("\(hoarder.downloadedEmojis.count) downloaded Emoji")
|
||||||
if hoarder.downloadedEmojis.count == hoarder.emojis.count {
|
if hoarder.downloadedEmojis.count == hoarder.emojis.count {
|
||||||
|
|||||||
Reference in New Issue
Block a user