mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
A coarse approximation of storage management UI
This commit is contained in:
@@ -91,10 +91,14 @@ public final class AllStorageUsageStats {
|
||||
}
|
||||
}
|
||||
|
||||
public var deviceAvailableSpace: Int64
|
||||
public var deviceFreeSpace: Int64
|
||||
public fileprivate(set) var totalStats: StorageUsageStats
|
||||
public fileprivate(set) var peers: [EnginePeer.Id: PeerStats]
|
||||
|
||||
public init(totalStats: StorageUsageStats, peers: [EnginePeer.Id: PeerStats]) {
|
||||
public init(deviceAvailableSpace: Int64, deviceFreeSpace: Int64, totalStats: StorageUsageStats, peers: [EnginePeer.Id: PeerStats]) {
|
||||
self.deviceAvailableSpace = deviceAvailableSpace
|
||||
self.deviceFreeSpace = deviceFreeSpace
|
||||
self.totalStats = totalStats
|
||||
self.peers = peers
|
||||
}
|
||||
@@ -242,7 +246,13 @@ func _internal_collectStorageUsageStats(account: Account) -> Signal<AllStorageUs
|
||||
}
|
||||
}
|
||||
|
||||
let systemAttributes = try? FileManager.default.attributesOfFileSystem(forPath: NSHomeDirectory() as String)
|
||||
let deviceAvailableSpace = (systemAttributes?[FileAttributeKey.systemSize] as? NSNumber)?.int64Value ?? 0
|
||||
let deviceFreeSpace = (systemAttributes?[FileAttributeKey.systemFreeSize] as? NSNumber)?.int64Value ?? 0
|
||||
|
||||
return AllStorageUsageStats(
|
||||
deviceAvailableSpace: deviceAvailableSpace,
|
||||
deviceFreeSpace: deviceFreeSpace,
|
||||
totalStats: total,
|
||||
peers: peers
|
||||
)
|
||||
@@ -257,7 +267,8 @@ func _internal_renderStorageUsageStatsMessages(account: Account, stats: StorageU
|
||||
if !categories.contains(category) {
|
||||
continue
|
||||
}
|
||||
for id in value.messages.keys {
|
||||
|
||||
for (id, _) in value.messages.sorted(by: { $0.value >= $1.value }).prefix(1000) {
|
||||
if result[id] == nil {
|
||||
if let message = existingMessages[id] {
|
||||
result[id] = message
|
||||
|
||||
Reference in New Issue
Block a user