Skip to content

Commit

Permalink
1.9.8 (448)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Feb 19, 2025
1 parent a7364e9 commit 2dfd37e
Show file tree
Hide file tree
Showing 25 changed files with 275 additions and 1,350 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.

21 changes: 18 additions & 3 deletions Nicegram/NGUI/Sources/NicegramSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import AccountContext
import Display
import FeatAiShortcuts
import FeatImagesHubUI
import FeatNicegramHub
import FeatPinnedChats
Expand Down Expand Up @@ -79,6 +80,7 @@ private enum NicegramSettingsControllerSection: Int32 {

private enum EasyToggleType {
case showNicegramButtonInChat
case showAiShortcutsInChat
case sendWithEnter
case showProfileId
case showRegDate
Expand Down Expand Up @@ -541,6 +543,11 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
switch (toggleType) {
case .showNicegramButtonInChat:
NGSettings.showNicegramButtonInChat = value
case .showAiShortcutsInChat:
Task {
let updateSettingsUseCase = AiShortcutsModule.shared.updateSettingsUseCase()
await updateSettingsUseCase.set(showInChat: value)
}
case .sendWithEnter:
NGSettings.sendWithEnter = value
case .showProfileId:
Expand Down Expand Up @@ -672,7 +679,7 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {

// MARK: Entries list

private func nicegramSettingsControllerEntries(presentationData: PresentationData, experimentalSettings: ExperimentalUISettings, showCalls: Bool, pinnedChats: [NicegramSettingsControllerEntry.PinnedChat], sharingSettings: SharingSettings?, context: AccountContext) -> [NicegramSettingsControllerEntry] {
private func nicegramSettingsControllerEntries(presentationData: PresentationData, experimentalSettings: ExperimentalUISettings, showCalls: Bool, pinnedChats: [NicegramSettingsControllerEntry.PinnedChat], sharingSettings: SharingSettings?, aiShortcutsSettings: FeatAiShortcuts.Settings, context: AccountContext) -> [NicegramSettingsControllerEntry] {
let nicegramSettings = getNicegramSettings()

var entries: [NicegramSettingsControllerEntry] = []
Expand Down Expand Up @@ -751,6 +758,9 @@ private func nicegramSettingsControllerEntries(presentationData: PresentationDat
entries.append(.easyToggle(toggleIndex, .showNicegramButtonInChat, l("ShowNicegramButtonInChat"), NGSettings.showNicegramButtonInChat))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .showAiShortcutsInChat, l("ShowAIShortcutsInChat"), aiShortcutsSettings.showInChat))
toggleIndex += 1

entries.append(.easyToggle(toggleIndex, .sendWithEnter, l("SendWithKb"), NGSettings.sendWithEnter))
toggleIndex += 1

Expand Down Expand Up @@ -940,8 +950,13 @@ public func nicegramSettingsController(context: AccountContext, accountsContexts
} else {
sharingSettingsSignal = .single(nil)
}

let aiShortcutsSettingsSignal = AiShortcutsModule.shared.getSettingsUseCase()
.publisher()
.toSignal()
.skipError()

let signal = combineLatest(context.sharedContext.presentationData, sharedDataSignal, showCallsTab, pinnedChatsSignal, sharingSettingsSignal) |> map { presentationData, sharedData, showCalls, pinnedChats, sharingSettings -> (ItemListControllerState, (ItemListNodeState, Any)) in
let signal = combineLatest(context.sharedContext.presentationData, sharedDataSignal, showCallsTab, pinnedChatsSignal, sharingSettingsSignal, aiShortcutsSettingsSignal) |> map { presentationData, sharedData, showCalls, pinnedChats, sharingSettings, aiShortcutsSettings -> (ItemListControllerState, (ItemListNodeState, Any)) in

let experimentalSettings: ExperimentalUISettings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings]?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings

Expand All @@ -952,7 +967,7 @@ public func nicegramSettingsController(context: AccountContext, accountsContexts
})
}

let entries = nicegramSettingsControllerEntries(presentationData: presentationData, experimentalSettings: experimentalSettings, showCalls: showCalls, pinnedChats: pinnedChats, sharingSettings: sharingSettings, context: context)
let entries = nicegramSettingsControllerEntries(presentationData: presentationData, experimentalSettings: experimentalSettings, showCalls: showCalls, pinnedChats: pinnedChats, sharingSettings: sharingSettings, aiShortcutsSettings: aiShortcutsSettings, context: context)
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(l("AppName")), leftNavigationButton: leftNavigationButton, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: entries, style: .blocks)

Expand Down
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git",
"state" : {
"branch" : "feat/NCG-7303_spy_on_friends",
"revision" : "bc342168e96b2bba4b4e9c816a067e62432da7c5"
"branch" : "feat/ai-shortcuts",
"revision" : "b6811d8dcbeca9525fdf8e7368fb020682fe173e"
}
},
{
Expand All @@ -123,7 +123,7 @@
"location" : "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git",
"state" : {
"branch" : "develop",
"revision" : "88e0a4c6160a3c491f48231093029299514e30a9"
"revision" : "35ee7a33d5f60d40f6d3857c107bd4d8b0769cd3"
}
},
{
Expand Down Expand Up @@ -356,8 +356,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/trustwallet/wallet-core.git",
"state" : {
"revision" : "b58fe8fef70e2a5446371e25cc2cc32dd003f978",
"version" : "4.2.10"
"revision" : "fd7a03e41b35e1d8e83b4e22a9f0d5d9b1c8b973",
"version" : "4.2.11"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "nicegram-package",
dependencies: [
.package(url: "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", branch: "feat/NCG-7303_spy_on_friends"),
.package(url: "git@bitbucket.org:mobyrix/nicegram-assistant-ios.git", branch: "feat/ai-shortcuts"),
.package(url: "git@bitbucket.org:mobyrix/nicegram-wallet-ios.git", branch: "develop")
]
)
4 changes: 1 addition & 3 deletions Telegram/Telegram-iOS/en.lproj/NiceLocalizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"Gmod.Disable" = "Disable Preview Mode?";

"ShowNicegramButtonInChat" = "Show Nicegram button in chat";
"ShowAIShortcutsInChat" = "Show AI Shortcuts in Chat";
"SendWithKb" = "Send with «Enter» button";
"NiceFeatures.ShowGmodIcon" = "Show Preview Mode icon";
"Gmod.OpenChatQ" = "Open chat?";
Expand Down Expand Up @@ -240,6 +241,3 @@
/*Stars Purchase*/
"StarsPurchase.GetOnFragment" = "Get on Fragment";
"StarsPurchase.GetOnTelegram" = "Get on Telegram";

/*Spy On Friends*/
"SpyOnFriends.Title" = "Activities";
2 changes: 1 addition & 1 deletion ng-env.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
prod
test
10 changes: 5 additions & 5 deletions submodules/ChatListUI/Sources/ChatListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
NGData.isPremium() {
let lastFolder = NGSettings.lastFolder
if lastFolder != -1 {
self.chatListDisplayNode.mainContainerNode.resetPendingItemNode()
self.selectTab(id: .filter(lastFolder))
self.selectTab(id: .filter(lastFolder), preselected: true)
}
}
}
Expand Down Expand Up @@ -4053,8 +4052,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
}))
}

private func selectTab(id: ChatListFilterTabEntryId) {
// MARK: Nicegram NCG-7102 bottom folders fix, preselected
private func selectTab(id: ChatListFilterTabEntryId, preselected: Bool = false) {
if self.parent == nil {
if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController {
for controller in navigationController.viewControllers {
Expand Down Expand Up @@ -4099,7 +4098,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if strongSelf.chatListDisplayNode.inlineStackContainerNode != nil {
strongSelf.setInlineChatList(location: nil)
}
strongSelf.chatListDisplayNode.mainContainerNode.switchToFilter(id: updatedFilter.flatMap { .filter($0.id) } ?? .all)
// MARK: Nicegram NCG-7102 bottom folders fix, preselected
strongSelf.chatListDisplayNode.mainContainerNode.switchToFilter(id: updatedFilter.flatMap { .filter($0.id) } ?? .all, preselected: preselected)
}
})
}
Expand Down
21 changes: 10 additions & 11 deletions submodules/ChatListUI/Sources/ChatListControllerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,7 @@ public final class ChatListContainerNode: ASDisplayNode, ASGestureRecognizerDele
}
}

public func switchToFilter(id: ChatListFilterTabEntryId, animated: Bool = true, completion: (() -> Void)? = nil) {
// MARK: Nicegram NCG-7102 bottom folders fix
ngLog("===NCG-7102=== switchToFilter: id = \(id), itemNodes = \(itemNodes), pendingItemNode = \(pendingItemNode)")
//
public func switchToFilter(id: ChatListFilterTabEntryId, animated: Bool = true, preselected: Bool = false, completion: (() -> Void)? = nil) {
self.onFilterSwitch?()
if id != self.selectedId, let index = self.availableFilters.firstIndex(where: { $0.id == id }) {
if let itemNode = self.itemNodes[id] {
Expand All @@ -834,6 +831,12 @@ public final class ChatListContainerNode: ASDisplayNode, ASGestureRecognizerDele
itemNode.emptyNode?.restartAnimation()
completion?()
} else if self.pendingItemNode == nil {
// MARK: Nicegram NCG-7102 bottom folders fix
var autoSetReady = !animated
if preselected {
autoSetReady = true
}
//
let itemNode = ChatListContainerItemNode(context: self.context, controller: self.controller, location: self.location, filter: self.availableFilters[index].filter, chatListMode: self.chatListMode, previewing: self.previewing, isInlineMode: self.isInlineMode, controlsHistoryPreload: self.controlsHistoryPreload, presentationData: self.presentationData, animationCache: self.animationCache, animationRenderer: self.animationRenderer, becameEmpty: { [weak self] filter in
self?.filterBecameEmpty(filter)
}, emptyAction: { [weak self] filter in
Expand All @@ -842,11 +845,12 @@ public final class ChatListContainerNode: ASDisplayNode, ASGestureRecognizerDele
self?.secondaryEmptyAction()
}, openArchiveSettings: { [weak self] in
self?.openArchiveSettings()
}, autoSetReady: !animated, isMainTab: index == 0)
// MARK: Nicegram NCG-7102 bottom folders fix, autoSetReady
}, autoSetReady: autoSetReady, isMainTab: index == 0)
self.pendingItemNode?.2.dispose()
let disposable = MetaDisposable()
self.pendingItemNode = (id, itemNode, disposable)

if !animated {
self.selectedId = id
self.applyItemNodeAsCurrent(id: id, itemNode: itemNode)
Expand Down Expand Up @@ -1056,11 +1060,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,35 @@ final class ChatSendMessageContextScreenComponent: Component {

var items: [ContextMenuItem] = []

// MARK: Nicegram AiChat
if textString.length > 0 {
let commands = TgChatAiHelper.getCommandsForInputText()
for command in commands {
items.append(.action(ContextMenuActionItem(
id: AnyHashable(command.id),
text: command.title,
icon: { _ in nil },
action: { [weak self] _, _ in
guard let self, let component = self.component else {
return
}
self.animateOutToEmpty = true

let request = TgChatAiRequst(
peerId: component.peerId?.id._internalGetInt64Value(),
command: command,
text: component.textInputView.text
)
TgChatAiHelper.send(request: request)

self.environment?.controller()?.dismiss()
}
)))
}
items.append(.separator)
}
//

let canAdjustMediaCaptionPosition: Bool
switch component.params {
case let .sendMessage(sendMessage):
Expand Down Expand Up @@ -672,40 +701,6 @@ final class ChatSendMessageContextScreenComponent: Component {
)))
}

// MARK: Nicegram AiChat
if let improveWritingCommand = TgChatAiHelper.improveWritingCommand() {
if case .separator = items.last {} else {
items.append(.separator)
}

items.append(.action(ContextMenuActionItem(
id: AnyHashable("improveWriting"),
text: improveWritingCommand.title,
icon: { theme in
generateTintedImage(
image: UIImage(systemName: "wand.and.stars"),
color: theme.contextMenu.primaryColor
)
},
action: { [weak self] _, _ in
guard let self, let component = self.component else {
return
}
self.animateOutToEmpty = true

let request = TgChatAiRequst(
peerId: component.peerId?.id._internalGetInt64Value(),
command: improveWritingCommand,
text: component.textInputView.text
)
TgChatAiHelper.send(request: request)

self.environment?.controller()?.dismiss()
}
)))
}
//

// MARK: Nicegram TranslateEnteredMessage
if component.nicegramData.canTranslate {
if case .separator = items.last {} else {
Expand Down
13 changes: 11 additions & 2 deletions submodules/Display/Source/Navigation/NavigationContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelega
}

public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
// MARK: Nicegram AiChat
if otherGestureRecognizer.name == "AiChatCommandsPanGestureRecognizer" {
// MARK: Nicegram
if otherGestureRecognizer.isNicegramExclusiveGesture() {
return false
}
//
Expand All @@ -214,6 +214,15 @@ public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelega
return false
}

// MARK: Nicegram
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if otherGestureRecognizer.isNicegramExclusiveGesture() {
return true
}
return false
}
//

@objc private func panGesture(_ recognizer: UIPanGestureRecognizer) {
switch recognizer.state {
case .began:
Expand Down
46 changes: 46 additions & 0 deletions submodules/Display/Source/Nicegram/NicegramUtils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import UIKit

private let nicegramViewIds = ["AiShortcutsView"]

extension UIGestureRecognizer {
func isNicegramExclusiveGesture() -> Bool {
view?.superviewSequence().contains {
if let accessibilityIdentifier = $0.accessibilityIdentifier {
nicegramViewIds.contains(accessibilityIdentifier)
} else {
false
}
} ?? false
}
}

// MARK: - Helpers

private extension UIView {
func superviewSequence() -> some Sequence<UIView> {
RecursiveSequence(value: self, nextValue: \.superview)
}
}

private struct RecursiveSequence<T>: Sequence {
let value: T
let nextValue: (T) -> T?

func makeIterator() -> RecursiveIterator<T> {
RecursiveIterator(value: value, nextValue: nextValue)
}
}

private struct RecursiveIterator<T>: IteratorProtocol {
var value: T?
let nextValue: (T) -> T?

mutating func next() -> T? {
guard let value else {
return nil
}

self.value = nextValue(value)
return value
}
}
5 changes: 5 additions & 0 deletions submodules/Display/Source/WindowContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ public final class WindowKeyboardGestureRecognizerDelegate: NSObject, UIGestureR
}

public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
// MARK: Nicegram
if otherGestureRecognizer.isNicegramExclusiveGesture() {
return false
}
//
return true
}

Expand Down
Loading

0 comments on commit 2dfd37e

Please sign in to comment.