Skip to content

Commit

Permalink
1.8.7 (358)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Oct 30, 2024
1 parent fd2a56b commit f9a3cbe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,5 +480,6 @@ public protocol PresentationCallManager: AnyObject {
func startRecordCall(with completion: @escaping () -> Void)
func stopRecordCall()
func setupPeer(peer: EnginePeer)
func showRecordSaveToast()
//
}
29 changes: 2 additions & 27 deletions submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
let isCallRecord = !callScreenState.isCallRecord
if isCallRecord {
self.sharedContext.callManager?.startRecordCall { [weak self] in
self?.showRecordSaveToast()
self?.sharedContext.callManager?.showRecordSaveToast()
}
self.updateCallRecordButton(with: isCallRecord)
} else {
Expand All @@ -179,7 +179,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
}

self.sharedContext.callManager?.callCompletion = { [weak self] in
self?.showRecordSaveToast()
self?.sharedContext.callManager?.showRecordSaveToast()
}
// MARK: Nicegram NCG-5828 call recording, isCallRecord
self.callScreenState = PrivateCallScreen.State(
Expand Down Expand Up @@ -784,31 +784,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
self.callScreenState = callScreenState
self.update(transition: .animated(duration: 0.3, curve: .spring))
}

private func showRecordSaveToast() {
guard let image = UIImage(bundleImageName: "RecordSave") else { return }

let content: UndoOverlayContent = .image(
image: image,
title: nil,
text: l("NicegramCallRecord.SavedMessage"),
round: true,
undoText: nil
)

DispatchQueue.main.async {
let controller = UndoOverlayController(
presentationData: self.presentationData,
content: content,
elevatedLayout: false,
position: .top,
animateInAsReplacement: false,
action: { _ in return false }
)

self.sharedContext.mainWindow?.present(controller, on: .root)
}
}
//
}

Expand Down
42 changes: 35 additions & 7 deletions submodules/TelegramCallsUI/Sources/PresentationCallManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import PhoneNumberFormat
// MARK: Nicegram NCG-5828 call recording
import NGLogging
import NGData
import NGStrings
import UndoUI
//
private func callKitIntegrationIfEnabled(_ integration: CallKitIntegration?, settings: VoiceCallSettings?) -> CallKitIntegration? {
Expand Down Expand Up @@ -321,7 +322,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
let autodownloadSettings = sharedData.entries[SharedDataKeys.autodownloadSettings]?.get(AutodownloadSettings.self) ?? .defaultSettings
let experimentalSettings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings]?.get(ExperimentalUISettings.self) ?? .defaultSettings
let appConfiguration = preferences.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue

let call = PresentationCallImpl(
context: firstState.0,
audioSession: strongSelf.audioSession,
Expand Down Expand Up @@ -349,7 +350,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
call.callActiveState = { [strongSelf] audioDevice in
strongSelf.callActiveState(
with: audioDevice,
account: firstState.0.account
accountContext: firstState.0
)
}
//
Expand Down Expand Up @@ -604,7 +605,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
call.callActiveState = { [strongSelf] audioDevice in
strongSelf.callActiveState(
with: audioDevice,
account: context.account
accountContext: context
)
}
//
Expand Down Expand Up @@ -974,7 +975,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
public var callCompletion: (() -> Void)?

private weak var audioDevice: OngoingCallContext.AudioDevice?
private var account: Account?
private var accountContext: AccountContext?
private var enginePeer: EnginePeer?
private var userDisplayName: String {
guard let enginePeer else { return "" }
Expand Down Expand Up @@ -1067,13 +1068,14 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
)

DispatchQueue.main.async {
if let account = self.account {
if let account = self.accountContext?.account {
let _ = enqueueMessages(
account: account,
peerId: account.peerId,
messages: [message]
).start(completed: { [weak self] in
self?.deleteFile(from: path)
self?.showRecordSaveToast()
completion?()
})
}
Expand All @@ -1082,11 +1084,11 @@ public final class PresentationCallManagerImpl: PresentationCallManager {

private func callActiveState(
with audioDevice: OngoingCallContext.AudioDevice?,
account: Account
accountContext: AccountContext
) {
if let audioDevice {
self.audioDevice = audioDevice
self.account = account
self.accountContext = accountContext
}

if NGSettings.recordAllCalls {
Expand Down Expand Up @@ -1116,5 +1118,31 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
public func setupPeer(peer: EnginePeer) {
self.enginePeer = peer
}

public func showRecordSaveToast() {
let (presentationData, _, _) = getDeviceAccessData()
guard let image = UIImage(bundleImageName: "RecordSave") else { return }

let content: UndoOverlayContent = .image(
image: image,
title: nil,
text: l("NicegramCallRecord.SavedMessage"),
round: true,
undoText: nil
)

DispatchQueue.main.async {
let controller = UndoOverlayController(
presentationData: presentationData,
content: content,
elevatedLayout: false,
position: .top,
animateInAsReplacement: false,
action: { _ in return false }
)

self.accountContext?.sharedContext.mainWindow?.present(controller, on: .root)
}
}
//
}

0 comments on commit f9a3cbe

Please sign in to comment.