Skip to content

Commit

Permalink
Release 1.7.4 (294)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Aug 15, 2024
1 parent f47f05b commit 3ef2281
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 45 deletions.
40 changes: 30 additions & 10 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 @@ -123,7 +123,7 @@
"location" : "[email protected]:mobyrix/nicegram-assistant-ios.git",
"state" : {
"branch" : "develop",
"revision" : "e47489635ad1e96913dd1da01d9b1164494c722d"
"revision" : "1b82457f99a129e8c97d8314b405e1e0e411a8a6"
}
},
{
Expand All @@ -132,7 +132,7 @@
"location" : "[email protected]:mobyrix/nicegram-wallet-ios.git",
"state" : {
"branch" : "develop",
"revision" : "60d741c4fbef9808061d0eb7df0207bd803cdcf2"
"revision" : "3a10f5bd47e6251a6bf4d8c80db11867cfc803d9"
}
},
{
Expand Down
6 changes: 5 additions & 1 deletion submodules/BrowserUI/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

NGDEPS = [
"@swiftpkg_nicegram_wallet_ios//:NicegramWallet",
]

swift_library(
name = "BrowserUI",
module_name = "BrowserUI",
Expand All @@ -9,7 +13,7 @@ swift_library(
copts = [
#"-warnings-as-errors",
],
deps = [
deps = NGDEPS + [
"//submodules/SSignalKit/SwiftSignalKit",
"//submodules/AsyncDisplayKit",
"//submodules/Display",
Expand Down
28 changes: 28 additions & 0 deletions submodules/BrowserUI/Sources/BrowserWebContent.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// MARK: Nicegram Wallet
import NicegramWallet
//
import Foundation
import UIKit
import Display
Expand Down Expand Up @@ -203,6 +206,10 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU

private var tempFile: TempBoxFile?

// MARK: Nicegram Wallet
private let nicegramWalletJsInjector = WalletJsInjector()
//

init(context: AccountContext, presentationData: PresentationData, url: String, preferredConfiguration: WKWebViewConfiguration? = nil) {
self.context = context
self.uuid = UUID()
Expand Down Expand Up @@ -319,6 +326,14 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
handleScriptMessageImpl = { [weak self] message in
self?.handleScriptMessage(message)
}

// MARK: Nicegram Wallet
nicegramWalletJsInjector.inject(
in: self.webView,
injectTonJs: false,
currentChain: { nil }
)
//
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -712,6 +727,13 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
// })
// } else {
if let url = navigationAction.request.url?.absoluteString {
// MARK: Nicegram Wallet
if nicegramWalletJsInjector.handle(url: url) {
decisionHandler(.cancel, preferences)
return
}
//

if (navigationAction.targetFrame == nil || navigationAction.targetFrame?.isMainFrame == true) && (isTelegramMeLink(url) || isTelegraPhLink(url)) && !url.contains("/auth/push?") && !self._state.url.contains("/auth/push?") {
decisionHandler(.cancel, preferences)
self.minimize()
Expand Down Expand Up @@ -788,6 +810,12 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
if navigationAction.targetFrame == nil {
if let url = navigationAction.request.url?.absoluteString {
// MARK: Nicegram Wallet
if nicegramWalletJsInjector.handle(url: url) {
return nil
}
//

if isTelegramMeLink(url) || isTelegraPhLink(url) {
self.minimize()
self.openAppUrl(url)
Expand Down
31 changes: 1 addition & 30 deletions submodules/TelegramUI/Sources/Nicegram/NGDeeplinkHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ class NGDeeplinkHandler {
}
return true
default:
showUpdateAppAlert()
return true
return false
}
}
}
Expand Down Expand Up @@ -228,34 +227,6 @@ private extension NGDeeplinkHandler {
}
return true
}

func showUpdateAppAlert() {
let alert = UIAlertController(
title: "Update the app",
message: "Please update the app to use the newest features!",
preferredStyle: .alert
)

alert.addAction(
UIAlertAction(
title: "Close",
style: .cancel
)
)

alert.addAction(
UIAlertAction(
title: "Update",
style: .default,
handler: { _ in
let urlOpener = CoreContainer.shared.urlOpener()
urlOpener.open(.appStoreAppUrl)
}
)
)

UIApplication.topViewController?.present(alert, animated: true)
}
}

// MARK: - Helpers
Expand Down
34 changes: 34 additions & 0 deletions submodules/TelegramUI/Sources/OpenUrl.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// MARK: Nicegram Deeplink
import NGCore
import NicegramWallet
//
import Foundation
Expand Down Expand Up @@ -1073,6 +1074,9 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur

if let convertedUrl = convertedUrl {
handleInternalUrl(convertedUrl)
// MARK: Nicegram Deeplink, added 'else' block
} else {
showUpdateAppAlert()
}
return
}
Expand Down Expand Up @@ -1180,3 +1184,33 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
continueHandling()
}
}

// MARK: Nicegram Deeplink
private func showUpdateAppAlert() {
let alert = UIAlertController(
title: "Update the app",
message: "Please update the app to use the newest features!",
preferredStyle: .alert
)

alert.addAction(
UIAlertAction(
title: "Close",
style: .cancel
)
)

alert.addAction(
UIAlertAction(
title: "Update",
style: .default,
handler: { _ in
let urlOpener = CoreContainer.shared.urlOpener()
urlOpener.open(.appStoreAppUrl)
}
)
)

UIApplication.topViewController?.present(alert, animated: true)
}
//
6 changes: 5 additions & 1 deletion submodules/WebUI/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

NGDEPS = [
"@swiftpkg_nicegram_wallet_ios//:NicegramWallet",
]

swift_library(
name = "WebUI",
module_name = "WebUI",
Expand All @@ -9,7 +13,7 @@ swift_library(
copts = [
#"-warnings-as-errors",
],
deps = [
deps = NGDEPS + [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display",
Expand Down
28 changes: 28 additions & 0 deletions submodules/WebUI/Sources/WebAppController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// MARK: Nicegram Wallet
import NicegramWallet
//
import Foundation
import UIKit
import WebKit
Expand Down Expand Up @@ -164,6 +167,10 @@ public final class WebAppController: ViewController, AttachmentContainable {

private var validLayout: (ContainerViewLayout, CGFloat)?

// MARK: Nicegram Wallet
private let nicegramWalletJsInjector = WalletJsInjector()
//

init(context: AccountContext, controller: WebAppController) {
self.context = context
self.controller = controller
Expand Down Expand Up @@ -301,6 +308,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
self.icon = icon
})

// MARK: Nicegram Wallet
nicegramWalletJsInjector.inject(
in: webView,
injectTonJs: false,
currentChain: { nil }
)
//
}

deinit {
Expand Down Expand Up @@ -431,6 +446,13 @@ public final class WebAppController: ViewController, AttachmentContainable {

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if let url = navigationAction.request.url?.absoluteString {
// MARK: Nicegram Wallet
if nicegramWalletJsInjector.handle(url: url) {
decisionHandler(.cancel)
return
}
//

if isTelegramMeLink(url) || isTelegraPhLink(url) {
decisionHandler(.cancel)
self.controller?.openUrl(url, true, {})
Expand All @@ -444,6 +466,12 @@ public final class WebAppController: ViewController, AttachmentContainable {

func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
if navigationAction.targetFrame == nil, let url = navigationAction.request.url {
// MARK: Nicegram Wallet
if nicegramWalletJsInjector.handle(url: url.absoluteString) {
return nil
}
//

self.controller?.openUrl(url.absoluteString, true, {})
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "1.7.2",
"app": "1.7.4",
"xcode": "15.2",
"bazel": "7.1.1",
"macos": "13.0"
Expand Down

0 comments on commit 3ef2281

Please sign in to comment.