mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Animation and other improvements
This commit is contained in:
parent
0d38a9bd08
commit
bacd88a1ff
37 changed files with 498 additions and 426 deletions
|
|
@ -43,6 +43,7 @@ public protocol AnimationCacheItemWriter: AnyObject {
|
|||
|
||||
public protocol AnimationCache: AnyObject {
|
||||
func get(sourceId: String, fetch: @escaping (AnimationCacheItemWriter) -> Disposable) -> Signal<AnimationCacheItem?, NoError>
|
||||
func getSynchronously(sourceId: String) -> AnimationCacheItem?
|
||||
}
|
||||
|
||||
private func md5Hash(_ string: String) -> String {
|
||||
|
|
@ -375,6 +376,18 @@ public final class AnimationCacheImpl: AnimationCache {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getSynchronously(sourceId: String) -> AnimationCacheItem? {
|
||||
let sourceIdPath = itemSubpath(hashString: md5Hash(sourceId))
|
||||
let itemDirectoryPath = "\(self.basePath)/\(sourceIdPath.directory)"
|
||||
let itemPath = "\(itemDirectoryPath)/\(sourceIdPath.fileName)"
|
||||
|
||||
if FileManager.default.fileExists(atPath: itemPath) {
|
||||
return loadItem(path: itemPath)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let queue: Queue
|
||||
|
|
@ -403,4 +416,10 @@ public final class AnimationCacheImpl: AnimationCache {
|
|||
}
|
||||
|> runOn(self.queue)
|
||||
}
|
||||
|
||||
public func getSynchronously(sourceId: String) -> AnimationCacheItem? {
|
||||
return self.impl.syncWith { impl -> AnimationCacheItem? in
|
||||
return impl.getSynchronously(sourceId: sourceId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue