mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-05 19:28:46 +02:00
Postbox -> TelegramEngine wave 24: moveResourceData facades + consumer sweep
Adds two TelegramEngine.Resources.moveResourceData overloads and migrates 6 Shape-A sites across 4 consumer files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d78fe8e8b8
commit
a0ba3fa29c
6 changed files with 36 additions and 6 deletions
22
CLAUDE.md
22
CLAUDE.md
|
|
@ -628,6 +628,28 @@ Net: 5 consumer files + 1 TelegramCore file + CLAUDE.md. TelegramEngineResources
|
|||
|
||||
Plan / record: (no plan doc this wave — mechanical sweep).
|
||||
|
||||
### Wave 24 outcome (2026-04-21)
|
||||
|
||||
`moveResourceData` facade additions + consumer sweep. Same shape as waves 21-23.
|
||||
|
||||
**Two facades added at `TelegramCore/Sources/TelegramEngine/Resources/TelegramEngineResources.swift`:**
|
||||
- `moveResourceData(id: EngineMediaResource.Id, toTempPath: String)` wraps the `(MediaResourceId, toTempPath:)` overload.
|
||||
- `moveResourceData(from: EngineMediaResource.Id, to: EngineMediaResource.Id, synchronous: Bool = false)` wraps the `(from: MediaResourceId, to: MediaResourceId, synchronous:)` overload.
|
||||
|
||||
Postbox's third overload `(MediaResourceId, fromTempPath:)` has no consumer-side usage; no facade added this wave (YAGNI).
|
||||
|
||||
**6 Shape-A consumer sites migrated (5 files):**
|
||||
- `TelegramUI/Sources/Chat/ChatControllerMediaRecording.swift` (1, `toTempPath:`)
|
||||
- `TelegramUI/Sources/OverlayAudioPlayerController.swift` (1, `from:to:synchronous:`)
|
||||
- `TelegramUI/Components/ComposePollScreen/Sources/ComposePollScreen.swift` (2)
|
||||
- `TelegramUI/Components/Chat/ChatMessagePollBubbleContentNode/Sources/ChatMessagePollBubbleContentNode.swift` (2)
|
||||
|
||||
**Build validation.** `bazel build Telegram/Telegram --keep_going` — clean first-pass build (563 processes, 272s, 0 errors).
|
||||
|
||||
Net: 5 consumer files + 1 TelegramCore file + CLAUDE.md. TelegramEngineResources.swift: +8 / -0. Consumer files: +6 / -6.
|
||||
|
||||
Plan / record: (no plan doc this wave — mechanical sweep).
|
||||
|
||||
### Modules currently free of `import Postbox` (running tally)
|
||||
|
||||
Consumer modules that no longer import Postbox, across all waves and standalone commits:
|
||||
|
|
|
|||
|
|
@ -468,5 +468,13 @@ public extension TelegramEngine {
|
|||
public func cancelInteractiveResourceFetch(id: EngineMediaResource.Id) {
|
||||
self.account.postbox.mediaBox.cancelInteractiveResourceFetch(resourceId: MediaResourceId(id.stringRepresentation))
|
||||
}
|
||||
|
||||
public func moveResourceData(id: EngineMediaResource.Id, toTempPath: String) {
|
||||
self.account.postbox.mediaBox.moveResourceData(MediaResourceId(id.stringRepresentation), toTempPath: toTempPath)
|
||||
}
|
||||
|
||||
public func moveResourceData(from: EngineMediaResource.Id, to: EngineMediaResource.Id, synchronous: Bool = false) {
|
||||
self.account.postbox.mediaBox.moveResourceData(from: MediaResourceId(from.stringRepresentation), to: MediaResourceId(to.stringRepresentation), synchronous: synchronous)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2283,7 +2283,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
case let .result(result):
|
||||
if case let .media(resultMedia) = result {
|
||||
if let resultImage = resultMedia.media as? TelegramMediaImage, let resultLargest = largestImageRepresentation(resultImage.representations) {
|
||||
item.context.account.postbox.mediaBox.moveResourceData(from: largest.resource.id, to: resultLargest.resource.id, synchronous: true)
|
||||
item.context.engine.resources.moveResourceData(from: EngineMediaResource.Id(largest.resource.id), to: EngineMediaResource.Id(resultLargest.resource.id), synchronous: true)
|
||||
}
|
||||
media.media = resultMedia
|
||||
media.progress = nil
|
||||
|
|
@ -2316,7 +2316,7 @@ public class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
|
|||
case let .result(result):
|
||||
if case let .media(resultMedia) = result {
|
||||
if let resultFile = resultMedia.media as? TelegramMediaFile {
|
||||
item.context.account.postbox.mediaBox.moveResourceData(from: file.resource.id, to: resultFile.resource.id, synchronous: true)
|
||||
item.context.engine.resources.moveResourceData(from: EngineMediaResource.Id(file.resource.id), to: EngineMediaResource.Id(resultFile.resource.id), synchronous: true)
|
||||
}
|
||||
media.media = resultMedia
|
||||
media.progress = nil
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ final class ComposePollScreenComponent: Component {
|
|||
switch result {
|
||||
case let .media(resultMedia):
|
||||
if let resultImage = resultMedia.media as? TelegramMediaImage, let resultLargest = largestImageRepresentation(resultImage.representations) {
|
||||
component.context.account.postbox.mediaBox.moveResourceData(from: largest.resource.id, to: resultLargest.resource.id, synchronous: true)
|
||||
component.context.engine.resources.moveResourceData(from: EngineMediaResource.Id(largest.resource.id), to: EngineMediaResource.Id(resultLargest.resource.id), synchronous: true)
|
||||
}
|
||||
|
||||
media.media = resultMedia
|
||||
|
|
@ -1029,7 +1029,7 @@ final class ComposePollScreenComponent: Component {
|
|||
switch result {
|
||||
case let .media(resultMedia):
|
||||
if let resultFile = resultMedia.media as? TelegramMediaFile {
|
||||
component.context.account.postbox.mediaBox.moveResourceData(from: file.resource.id, to: resultFile.resource.id, synchronous: true)
|
||||
component.context.engine.resources.moveResourceData(from: EngineMediaResource.Id(file.resource.id), to: EngineMediaResource.Id(resultFile.resource.id), synchronous: true)
|
||||
}
|
||||
media.media = resultMedia
|
||||
media.progress = nil
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ extension ChatControllerImpl {
|
|||
let randomId = Int64.random(in: Int64.min ... Int64.max)
|
||||
let tempPath = NSTemporaryDirectory() + "\(Int64.random(in: 0 ..< .max)).ogg"
|
||||
resource = LocalFileAudioMediaResource(randomId: randomId, path: tempPath, trimRange: trimRange)
|
||||
self.context.account.postbox.mediaBox.moveResourceData(audio.resource.id, toTempPath: tempPath)
|
||||
self.context.engine.resources.moveResourceData(id: EngineMediaResource.Id(audio.resource.id), toTempPath: tempPath)
|
||||
waveform = waveform.subwaveform(from: trimRange.lowerBound / Double(audio.duration), to: trimRange.upperBound / Double(audio.duration))
|
||||
finalDuration = Int(trimRange.upperBound - trimRange.lowerBound)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ final class OverlayAudioPlayerControllerImpl: ViewController, OverlayAudioPlayer
|
|||
switch result {
|
||||
case let .media(resultMedia):
|
||||
if let resultFile = resultMedia.media as? TelegramMediaFile {
|
||||
self.context.account.postbox.mediaBox.moveResourceData(from: file.resource.id, to: resultFile.resource.id, synchronous: true)
|
||||
self.context.engine.resources.moveResourceData(from: EngineMediaResource.Id(file.resource.id), to: EngineMediaResource.Id(resultFile.resource.id), synchronous: true)
|
||||
self.controllerNode.addToSavedMusic(file: .standalone(media: file))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue