mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-06-08 11:03:55 +02:00
fix: three critical bugs in scheduled send and account switcher
Bug 1 — Video recorder freeze with SendDelayManager enabled
When SendDelayManager is active, video notes (кружки) and media are
enqueued into Namespaces.Message.ScheduledLocal, not the main chat
history. This broke setupSendActionOnViewUpdate which expects the message
to appear in the regular history before triggering its callback (dismiss
recorder, collapse input). The callback never fired → recorder overlay
stayed on screen → app froze.
Fix: in requestVideoRecorder's completion closure, detect when
SendDelayManager.shared.isEnabled, immediately dismiss the recorder and
clear the interface state, bypassing the broken animation path.
Bug 2 — Scheduled messages remain visible after being sent
When AntiDeleteManager is enabled, the .DeleteMessages case in
AccountStateManagementUtils uses to skip non-Cloud namespaces
(ScheduledCloud, ScheduledLocal). However after the loop no code
physically removed those skipped messages from Postbox — they stayed
in the scheduled list forever, appearing as 'planned' messages that
never disappeared.
Fix: collect non-Cloud IDs during the Anti-Delete loop and physically
delete them via _internal_deleteMessages after the loop.
Bug 3 — Account switcher avatar not loading
Race condition in avatar loading: resourceData was subscribed to first,
then fetchedMediaResource triggered the network fetch. The signal's
callback fired before data arrived, calling buildButton(nil)
which discarded the real avatar.
Fix: trigger fetchedMediaResource first, then subscribe to resourceData
with filter { $0.complete } |> take(1) so the signal stays alive until
the download completes.
This commit is contained in:
@@ -6695,20 +6695,10 @@ private final class ChatListLocationContext {
|
||||
let resource = representation.resource
|
||||
let account = nextAccount.account
|
||||
|
||||
// Try to read cached data first; if not ready, trigger a fetch then watch for completion
|
||||
self.accountSwitcherAvatarDisposable = (account.postbox.mediaBox
|
||||
.resourceData(resource)
|
||||
|> deliverOnMainQueue)
|
||||
.start(next: { data in
|
||||
if data.complete, let uiImage = UIImage(contentsOfFile: data.path) {
|
||||
buildButton(uiImage)
|
||||
}
|
||||
}, completed: {
|
||||
// If resource was never complete after signal ended, show placeholder
|
||||
buildButton(nil)
|
||||
})
|
||||
|
||||
// Trigger the actual network fetch so mediaBox populates the resource
|
||||
// GHOSTGRAM: Fetch first so the resource is populated by the time
|
||||
// resourceData emits a complete result. The old order (subscribe→fetch)
|
||||
// had a race where `completed` fired before data arrived, causing
|
||||
// buildButton(nil) to be called and the avatar to never show.
|
||||
if let peerReference = PeerReference(nextPeer) {
|
||||
let _ = fetchedMediaResource(
|
||||
mediaBox: account.postbox.mediaBox,
|
||||
@@ -6717,6 +6707,19 @@ private final class ChatListLocationContext {
|
||||
reference: .avatar(peer: peerReference, resource: resource)
|
||||
).start()
|
||||
}
|
||||
|
||||
self.accountSwitcherAvatarDisposable = (account.postbox.mediaBox
|
||||
.resourceData(resource)
|
||||
|> filter { $0.complete }
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue)
|
||||
.start(next: { data in
|
||||
if let uiImage = UIImage(contentsOfFile: data.path) {
|
||||
buildButton(uiImage)
|
||||
} else {
|
||||
buildButton(nil)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// No photo — show placeholder
|
||||
buildButton(nil)
|
||||
|
||||
Reference in New Issue
Block a user