Postbox -> TelegramEngine wave 21: completedResourcePath facade + consumer sweep
Combined wave-19+wave-20 shape. Adds TelegramEngine.Resources.completedResourcePath(id:, pathExtension:) facade and sweeps 29 consumer sites across 14 files in one atomic commit. Shape A/B migrated. Shape C (5 sites with raw account: Account) and Shape D (3 sites with local postbox: Postbox field) intentionally skipped — need module-scoped init-signature rework rather than per-site sweep. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7919556375
commit
53f023ea52
17 changed files with 70 additions and 31 deletions
35
CLAUDE.md
35
CLAUDE.md
|
|
@ -529,6 +529,41 @@ Net: 16 files changed, all edits mechanical (before → after): +22 insertions /
|
|||
|
||||
Plan / record: (no plan doc this wave — mechanical sweep).
|
||||
|
||||
### Wave 21 outcome (2026-04-21)
|
||||
|
||||
Combined wave-19+wave-20 shape: facade addition + consumer sweep in a single atomic commit. Adds `TelegramEngine.Resources.completedResourcePath(id: EngineMediaResource.Id, pathExtension: String? = nil) -> String?` facade; sweeps 29 consumer sites across 14 files.
|
||||
|
||||
**Facade added at `TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift:460`.** Body: `self.account.postbox.mediaBox.completedResourcePath(id: MediaResourceId(id.stringRepresentation), pathExtension: pathExtension)`. Wraps the Postbox `MediaBox.completedResourcePath(id: MediaResourceId, pathExtension: String?)` overload; consumers that previously called the resource-taking overload (`MediaBox.completedResourcePath(_ resource: MediaResource, …)`) migrate through the id path (`.resource.id` is already `MediaResourceId`).
|
||||
|
||||
**28 Shape-A consumer sites + 1 Shape-B (already-id-overload) migrated:**
|
||||
- `SettingsUI/Sources/Themes/EditThemeController.swift` (1 site)
|
||||
- `BrowserUI/Sources/BrowserPdfContent.swift` (1 site)
|
||||
- `BrowserUI/Sources/BrowserDocumentContent.swift` (1 site)
|
||||
- `GalleryUI/Sources/SecretMediaPreviewController.swift` (1 site)
|
||||
- `TelegramUI/Components/MediaEditor/Sources/MediaEditor.swift` (1 site, `pathExtension: "mp4"`)
|
||||
- `TelegramUI/Components/Settings/WallpaperGridScreen/Sources/WallpaperUtils.swift` (7 sites across 3 functions; 4 unique expression templates, handled via `replace_all=true` where identical)
|
||||
- `TelegramUI/Components/Settings/ThemeAccentColorScreen/Sources/ThemeAccentColorController.swift` (1 site)
|
||||
- `TelegramUI/Components/Settings/WallpaperGalleryScreen/Sources/WallpaperGalleryController.swift` (5 sites; 4 used `resource` expr identically via `replace_all=true`, 1 used `file.file.resource`)
|
||||
- `TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift` (1 site, `pathExtension: nil`)
|
||||
- `TelegramUI/Components/Chat/ChatMessageWebpageBubbleContentNode/Sources/ChatMessageWebpageBubbleContentNode.swift` (1 site)
|
||||
- `TelegramUI/Components/Chat/ChatMessageMediaBubbleContentNode/Sources/ChatMessageMediaBubbleContentNode.swift` (7 sites, all identical `telegramFile.resource` — handled via `replace_all=true`)
|
||||
- `TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift` (1 site)
|
||||
- `TelegramUI/Sources/OpenChatMessage.swift` (1 site)
|
||||
- `TelegramUI/Sources/Chat/ChatControllerMediaRecording.swift` (1 site)
|
||||
- `TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemImageView.swift` (1 site, Shape B — was already using the `id:` overload; migrated identically to `EngineMediaResource.Id(...)`)
|
||||
|
||||
**8 sites intentionally skipped (Shape C/D).** Listed in the plan — 5 Shape-C sites that access a raw `account: Account` parameter (no `.engine` on `Account`) and 3 Shape-D sites that carry a local `postbox: Postbox` stored field. Both shapes need module-scoped init-signature rework rather than per-site sweep; defer to future waves.
|
||||
|
||||
**No modules became Postbox-free.** Each consumer has other Postbox usage (signatures, transactions, other mediaBox calls). Matches waves 19/20's expectation.
|
||||
|
||||
**Build validation.** `bazel build Telegram/Telegram --keep_going` — clean first-pass build (569 processes, 1556 action cache hits + 30 local + 532 worker, 240s, 0 errors, `Telegram.ipa` up-to-date).
|
||||
|
||||
**Pattern validation.** Wave-shape G (facade addition + consumer sweep in a single commit) works well when the consumer pool is bounded and mechanical. 29 sites in 14 files is comfortably within the threshold. Kept waves 19 and 20 separate because 25+ sites across that many modules was at the edge of reviewability; wave 21's similar fan-out fits because the plan pre-classified every site by shape. When the plan does the classification work upfront, combined waves are cheaper to review and ship.
|
||||
|
||||
Net: 14 files changed. TelegramEngineResources.swift: +4 / -0. Consumer files: +29 / -29 (mechanical rewrite at each site). CLAUDE.md: +outcome paragraph.
|
||||
|
||||
Plan / record: `memory/project_postbox_wave21_plan.md` (deleted post-commit per the plan's own housekeeping instructions).
|
||||
|
||||
### Modules currently free of `import Postbox` (running tally)
|
||||
|
||||
Consumer modules that no longer import Postbox, across all waves and standalone commits:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate
|
|||
|
||||
var title: String = "file"
|
||||
var url = ""
|
||||
if let path = self.context.account.postbox.mediaBox.completedResourcePath(file.media.resource) {
|
||||
if let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.media.resource.id)) {
|
||||
var updatedPath = path
|
||||
if let fileName = file.media.fileName {
|
||||
let tempFile = TempBox.shared.file(path: path, fileName: fileName)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ final class BrowserPdfContent: UIView, BrowserContent, UIScrollViewDelegate, PDF
|
|||
|
||||
var title = "file"
|
||||
var url = ""
|
||||
if let path = self.context.account.postbox.mediaBox.completedResourcePath(file.media.resource) {
|
||||
if let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.media.resource.id)) {
|
||||
var updatedPath = path
|
||||
if let fileName = file.media.fileName {
|
||||
let tempFile = TempBox.shared.file(path: path, fileName: fileName)
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ public final class SecretMediaPreviewController: ViewController {
|
|||
var duration: Double = 0.0
|
||||
for media in message.media {
|
||||
if let file = media as? TelegramMediaFile {
|
||||
if let path = self.context.account.postbox.mediaBox.completedResourcePath(file.resource) {
|
||||
if let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.resource.id)) {
|
||||
let tempFile = TempBox.shared.file(path: path, fileName: file.fileName ?? "file")
|
||||
self.tempFile = tempFile
|
||||
tempFilePath = tempFile.path
|
||||
|
|
|
|||
|
|
@ -612,7 +612,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
|
|||
let resource = file.file.resource
|
||||
|
||||
var data: Data?
|
||||
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
} else if let path = context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
|
|
|
|||
|
|
@ -456,5 +456,9 @@ public extension TelegramEngine {
|
|||
public func shortLivedResourceCachePathPrefix(id: EngineMediaResource.Id) -> String {
|
||||
return self.account.postbox.mediaBox.shortLivedResourceCachePathPrefix(MediaResourceId(id.stringRepresentation))
|
||||
}
|
||||
|
||||
public func completedResourcePath(id: EngineMediaResource.Id, pathExtension: String? = nil) -> String? {
|
||||
return self.account.postbox.mediaBox.completedResourcePath(id: MediaResourceId(id.stringRepresentation), pathExtension: pathExtension)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
|||
if case .full = contentMediaAutomaticDownload {
|
||||
willDownloadOrLocal = true
|
||||
} else {
|
||||
willDownloadOrLocal = context.account.postbox.mediaBox.completedResourcePath(file.resource) != nil
|
||||
willDownloadOrLocal = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.resource.id)) != nil
|
||||
}
|
||||
if willDownloadOrLocal {
|
||||
contentMediaAutomaticPlayback = true
|
||||
|
|
|
|||
|
|
@ -158,13 +158,13 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
} else if (telegramFile.isVideo && !telegramFile.isAnimated) && item.context.sharedContext.energyUsageSettings.autoplayVideo {
|
||||
if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
} else if (telegramFile.isVideo && !telegramFile.isAnimated) && item.context.sharedContext.energyUsageSettings.autoplayVideo {
|
||||
if let _ = telegramFile.videoCover {
|
||||
|
|
@ -194,7 +194,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
} else if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
} else if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
} else if (telegramFile.isVideo && !telegramFile.isAnimated) && item.context.sharedContext.energyUsageSettings.autoplayVideo {
|
||||
if let _ = telegramFile.videoCover {
|
||||
|
|
@ -275,7 +275,7 @@ public class ChatMessageMediaBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
} else if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(telegramFile.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(telegramFile.resource.id)) != nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
|
|||
if case .full = automaticDownload {
|
||||
automaticPlayback = true
|
||||
} else {
|
||||
automaticPlayback = item.context.account.postbox.mediaBox.completedResourcePath(file.resource) != nil
|
||||
automaticPlayback = item.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.resource.id)) != nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -837,7 +837,7 @@ public final class MediaEditor {
|
|||
|> mapToSignal { message in
|
||||
var player: AVPlayer?
|
||||
if let message, !"".isEmpty {
|
||||
if let maybeFile = message.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, maybeFile.isVideo, let path = self.context.account.postbox.mediaBox.completedResourcePath(maybeFile.resource, pathExtension: "mp4") {
|
||||
if let maybeFile = message.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, maybeFile.isVideo, let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(maybeFile.resource.id), pathExtension: "mp4") {
|
||||
let asset = AVURLAsset(url: URL(fileURLWithPath: path))
|
||||
player = self.makePlayer(asset: asset)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3750,7 +3750,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
|
|||
return
|
||||
}
|
||||
var messageFile: TelegramMediaFile?
|
||||
if let maybeFile = messages.first?.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, maybeFile.isVideo, let _ = self.context.account.postbox.mediaBox.completedResourcePath(maybeFile.resource, pathExtension: nil) {
|
||||
if let maybeFile = messages.first?.media.first(where: { $0 is TelegramMediaFile }) as? TelegramMediaFile, maybeFile.isVideo, let _ = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(maybeFile.resource.id), pathExtension: nil) {
|
||||
messageFile = maybeFile
|
||||
}
|
||||
if "".isEmpty {
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public final class ThemeAccentColorController: ViewController {
|
|||
let resource = file.file.resource
|
||||
|
||||
var data: Data?
|
||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
} else if let path = strongSelf.context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
if let resource = resource {
|
||||
let representation = CachedBlurredWallpaperRepresentation()
|
||||
var data: Data?
|
||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
} else if let path = strongSelf.context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
|
|
@ -654,7 +654,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
if let resource = resource {
|
||||
let representation = CachedBlurredWallpaperRepresentation()
|
||||
var data: Data?
|
||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
} else if let path = strongSelf.context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
|
|
@ -674,7 +674,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
if wallpaper.isPattern, !file.settings.colors.isEmpty, let _ = file.settings.intensity {
|
||||
var data: Data?
|
||||
var thumbnailData: Data?
|
||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
} else if let path = strongSelf.context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
data = maybeData
|
||||
|
|
@ -683,7 +683,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
let thumbnailResource = file.file.previewRepresentations.first?.resource
|
||||
|
||||
if let resource = thumbnailResource {
|
||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
thumbnailData = maybeData
|
||||
} else if let path = strongSelf.context.sharedContext.accountManager.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
thumbnailData = maybeData
|
||||
|
|
@ -697,7 +697,7 @@ public class WallpaperGalleryController: ViewController {
|
|||
}
|
||||
completion(wallpaper)
|
||||
}
|
||||
} else if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(file.file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
} else if let path = strongSelf.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.file.resource.id)), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
strongSelf.context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data)
|
||||
completion(wallpaper)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperG
|
|||
case let .wallpaper(wallpaper, _):
|
||||
switch wallpaper {
|
||||
case let .file(file):
|
||||
if let path = context.account.postbox.mediaBox.completedResourcePath(file.file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.file.resource.id)), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data)
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedBlurredWallpaperRepresentation(), complete: true, fetch: true).start()
|
||||
|
|
@ -26,7 +26,7 @@ public func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperG
|
|||
case let .image(representations, _):
|
||||
for representation in representations {
|
||||
let resource = representation.resource
|
||||
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data)
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public func uploadCustomWallpaper(context: AccountContext, wallpaper: WallpaperG
|
|||
}
|
||||
|
||||
if let imageResource = imageResource {
|
||||
imageSignal = .single(context.account.postbox.mediaBox.completedResourcePath(imageResource))
|
||||
imageSignal = .single(context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(imageResource.id)))
|
||||
|> mapToSignal { path -> Signal<UIImage, NoError> in
|
||||
if let path = path, let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedIfSafe]), let image = UIImage(data: data) {
|
||||
return .single(image)
|
||||
|
|
@ -198,7 +198,7 @@ public func getTemporaryCustomPeerWallpaper(context: AccountContext, wallpaper:
|
|||
}
|
||||
|
||||
if let imageResource = imageResource {
|
||||
imageSignal = .single(context.account.postbox.mediaBox.completedResourcePath(imageResource))
|
||||
imageSignal = .single(context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(imageResource.id)))
|
||||
|> mapToSignal { path -> Signal<UIImage, NoError> in
|
||||
if let path = path, let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedIfSafe]), let image = UIImage(data: data) {
|
||||
return .single(image)
|
||||
|
|
@ -264,7 +264,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa
|
|||
imageSignal = .complete()
|
||||
switch wallpaper {
|
||||
case let .file(file):
|
||||
if let path = context.account.postbox.mediaBox.completedResourcePath(file.file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let image = UIImage(data: data) {
|
||||
if let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(file.file.resource.id)), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let image = UIImage(data: data) {
|
||||
context.sharedContext.accountManager.mediaBox.storeResourceData(file.file.resource.id, data: data, synchronous: true)
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedBlurredWallpaperRepresentation(), complete: true, fetch: true).start()
|
||||
|
|
@ -274,7 +274,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa
|
|||
case let .image(representations, _):
|
||||
for representation in representations {
|
||||
let resource = representation.resource
|
||||
if let path = context.account.postbox.mediaBox.completedResourcePath(resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
if let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(resource.id)), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||
context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||
let _ = context.sharedContext.accountManager.mediaBox.cachedResourceRepresentation(resource, representation: CachedScaledImageRepresentation(size: CGSize(width: 720.0, height: 720.0), mode: .aspectFit), complete: true, fetch: true).start()
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa
|
|||
}
|
||||
|
||||
if let imageResource = imageResource {
|
||||
imageSignal = .single(context.account.postbox.mediaBox.completedResourcePath(imageResource))
|
||||
imageSignal = .single(context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(imageResource.id)))
|
||||
|> mapToSignal { path -> Signal<UIImage, NoError> in
|
||||
if let path = path, let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedIfSafe]), let image = UIImage(data: data) {
|
||||
return .single(image)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ final class StoryItemImageView: UIView {
|
|||
dimensions = representation.dimensions.cgSize
|
||||
|
||||
if isMediaUpdated {
|
||||
if attemptSynchronous, let path = context.account.postbox.mediaBox.completedResourcePath(id: representation.resource.id, pathExtension: nil) {
|
||||
if attemptSynchronous, let path = context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(representation.resource.id), pathExtension: nil) {
|
||||
if #available(iOS 15.0, *) {
|
||||
if let image = UIImage(contentsOfFile: path)?.preparingForDisplay() {
|
||||
self.updateImage(image: image, isCaptureProtected: isCaptureProtected)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ extension ChatControllerImpl {
|
|||
}
|
||||
|
||||
var resumeData: AudioRecorderResumeData?
|
||||
if let existingDraft, let path = self.context.account.postbox.mediaBox.completedResourcePath(existingDraft.resource), let compressedData = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedIfSafe]), let recorderResumeData = existingDraft.resumeData {
|
||||
if let existingDraft, let path = self.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(existingDraft.resource.id)), let compressedData = try? Data(contentsOf: URL(fileURLWithPath: path), options: [.mappedIfSafe]), let recorderResumeData = existingDraft.resumeData {
|
||||
resumeData = AudioRecorderResumeData(compressedData: compressedData, resumeData: recorderResumeData)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
|||
}), .window(.root))
|
||||
case let .theme(media):
|
||||
params.dismissInput()
|
||||
let path = params.context.account.postbox.mediaBox.completedResourcePath(media.resource)
|
||||
let path = params.context.engine.resources.completedResourcePath(id: EngineMediaResource.Id(media.resource.id))
|
||||
var previewTheme: PresentationTheme?
|
||||
if let path = path, let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe) {
|
||||
previewTheme = makePresentationTheme(data: data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue