Skip to content

Commit

Permalink
1.9.7 (442)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Feb 12, 2025
1 parent 09e82ae commit e68a4c7
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 17 deletions.
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/trustwallet/wallet-core.git",
"state" : {
"revision" : "e55a95330d61bfe29a8ee9dac87afb59fe20ab73",
"version" : "4.2.9"
"revision" : "b58fe8fef70e2a5446371e25cc2cc32dd003f978",
"version" : "4.2.10"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,6 @@ public protocol PresentationCallManager: AnyObject {
func stopRecordCall(needStopPartTimer: Bool)
func setupPeer(peer: EnginePeer)
func showRecordSaveToast()
func stopPartTimer()
//
}
3 changes: 2 additions & 1 deletion submodules/ChatListUI/Sources/ChatListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,13 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
_ = (self.ready.get() |> deliverOnMainQueue)
.start { [weak self] flag in
guard let self else { return }

if flag,
NGSettings.rememberFolderOnExit,
NGData.isPremium() {
let lastFolder = NGSettings.lastFolder
if lastFolder != -1 {
self.chatListDisplayNode.mainContainerNode.resetPendingItemNode()
self.selectTab(id: .filter(lastFolder))
}
}
Expand Down
5 changes: 5 additions & 0 deletions submodules/ChatListUI/Sources/ChatListControllerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,11 @@ public final class ChatListContainerNode: ASDisplayNode, ASGestureRecognizerDele
}
}
}
// MARK: Nicegram NCG-7102 bottom folders fix
public func resetPendingItemNode() {
self.pendingItemNode = nil
}
//
}

final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
Expand Down
3 changes: 3 additions & 0 deletions submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
return
}
self.endCall?()
// MARK: Nicegram NCG-5828 call recording
self.sharedContext.callManager?.stopPartTimer()
//
}
self.callScreen.backAction = { [weak self] in
guard let self else {
Expand Down
11 changes: 5 additions & 6 deletions submodules/TelegramCallsUI/Sources/PresentationCallManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {

return dateFormatter
}()
private let partLength: TimeInterval = 60 * 30
private let partLength: TimeInterval = 30 * 60

public func startRecordCall(
with completion: @escaping () -> Void
Expand Down Expand Up @@ -1105,7 +1105,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
randomId: id
)
let text = if partNumber > 1 {
"\(userDisplayName)-\(dateFormatter.string(from: date))- part \(partNumber)"
"\(userDisplayName)-\(dateFormatter.string(from: date))-part-\(partNumber)"
} else {
"\(userDisplayName)-\(dateFormatter.string(from: date))"
}
Expand All @@ -1126,8 +1126,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
title: "",
performer: nil,
waveform: nil
),
.FileName(fileName: text)
)
],
alternativeRepresentations: []
)
Expand Down Expand Up @@ -1160,6 +1159,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
)
}
}, completed: { [weak self] in
self?.partNumber += 1
self?.deleteFile(from: path)
self?.showRecordSaveToast()
sendCallRecorderAnalytics(with: .end)
Expand Down Expand Up @@ -1187,13 +1187,12 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
let timer = Foundation.Timer(timeInterval: partLength, repeats: true) { [weak self] _ in
self?.stopRecordCall(needStopPartTimer: false)
self?.startRecordCall {}
self?.partNumber += 1
}
self.partTimer = timer
RunLoop.main.add(timer, forMode: .common)
}

private func stopPartTimer() {
public func stopPartTimer() {
partTimer?.invalidate()
partTimer = nil
}
Expand Down
111 changes: 106 additions & 5 deletions submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import NGUI
import PeerInfoUI
import NGData
import NGSpeechToText
import AVFoundation
//
import TranslateUI
import DebugSettingsUI
Expand Down Expand Up @@ -495,7 +496,9 @@ func updatedChatEditInterfaceMessageState(context: AccountContext, state: ChatPr
previewState
)
}

// MARK: Nicegram NCG-5828 call recording
var saveMediaDisposable: MetaDisposable?
//
func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, messages: [Message], controllerInteraction: ChatControllerInteraction?, selectAll: Bool, interfaceInteraction: ChatPanelInterfaceInteraction?, readStats: MessageReadStats? = nil, messageNode: ChatMessageItemView? = nil) -> Signal<ContextController.Items, NoError> {
guard let interfaceInteraction = interfaceInteraction, let controllerInteraction = controllerInteraction else {
return .single(ContextController.Items(content: .list([])))
Expand Down Expand Up @@ -944,7 +947,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState

return (data, updatingMessageMedia, infoSummaryData, appConfig, isMessageRead, messageViewsPrivacyTips, availableReactions, translationSettings, loggingSettings, notificationSoundList, accountPeer)
}

return dataSignal
|> deliverOnMainQueue
|> map { data, updatingMessageMedia, infoSummaryData, appConfig, isMessageRead, messageViewsPrivacyTips, availableReactions, translationSettings, loggingSettings, notificationSoundList, accountPeer -> ContextController.Items in
Expand Down Expand Up @@ -1496,10 +1499,108 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
}
// MARK: Nicegram NCG-5828 call recording
else if file.isVoice {
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_SaveToFiles, icon: { theme in
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.WebBrowser_Download_Download, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Save"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
controllerInteraction.saveMediaToFiles(message.id)
}, action: { _, f in
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Messages.Message(id: message.id))
|> deliverOnMainQueue).startStandalone(next: { message in
guard let message else {
return
}
var file: TelegramMediaFile?
let title: String = message.text

for media in message.media {
if let mediaFile = media as? TelegramMediaFile, mediaFile.isVoice {
file = mediaFile
}
}

guard let file else {
return
}

var signal = fetchMediaData(context: context, postbox: context.account.postbox, userLocation: .other, mediaReference: .message(message: MessageReference(message._asMessage()), media: file))

let disposable: MetaDisposable
if let current = saveMediaDisposable {
disposable = current
} else {
disposable = MetaDisposable()
saveMediaDisposable = disposable
}

var cancelImpl: (() -> Void)?
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let progressSignal = Signal<Never, NoError> { subscriber in
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
cancelImpl?()
}))
controllerInteraction.presentController(controller, nil)
return ActionDisposable { [weak controller] in
Queue.mainQueue().async() {
controller?.dismiss()
}
}
}
|> runOn(Queue.mainQueue())
|> delay(0.15, queue: Queue.mainQueue())
let progressDisposable = progressSignal.startStrict()

signal = signal
|> afterDisposed {
Queue.mainQueue().async {
progressDisposable.dispose()
}
}
cancelImpl = { [weak disposable] in
disposable?.set(nil)
}
disposable.set((signal
|> deliverOnMainQueue).startStrict(next: { state, _ in
switch state {
case .progress:
break
case let .data(data):
if data.complete {
var symlinkPath = data.path + ".ogg"
if fileSize(symlinkPath) != nil {
try? FileManager.default.removeItem(atPath: symlinkPath)
}
let _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath)

let audioUrl = URL(fileURLWithPath: symlinkPath)
let audioAsset = AVURLAsset(url: audioUrl)

var fileExtension = "ogg"

if let filename = file.fileName {
if let dotIndex = filename.lastIndex(of: ".") {
fileExtension = String(filename[filename.index(after: dotIndex)...])
}
}

var nameComponents: [String] = []
if !title.isEmpty {
nameComponents.append(title)
}

if !nameComponents.isEmpty {
try? FileManager.default.removeItem(atPath: symlinkPath)

let fileName = "\(nameComponents.joined(separator: "")).\(fileExtension)"
symlinkPath = symlinkPath.replacingOccurrences(of: audioUrl.lastPathComponent, with: fileName)
let _ = try? FileManager.default.linkItem(atPath: data.path, toPath: symlinkPath)
}

let url = URL(fileURLWithPath: symlinkPath)

let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
context.sharedContext.applicationBindings.presentNativeController(activityController)
}
}
}))
})
f(.default)
})))
}
Expand Down

0 comments on commit e68a4c7

Please sign in to comment.