-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into version/0.40
- Loading branch information
Showing
19 changed files
with
562 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ swap_enabled = true | |
donate_enabled = true | ||
|
||
default_words = | ||
referral_app_server_url = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,6 @@ class DeepLinkService { | |
} | ||
|
||
func setDeepLinkShown() { | ||
deepLink = nil | ||
deepLinkManager.setDeepLinkShown() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
UnstoppableWallet/UnstoppableWallet/Modules/Main/Workers/TelegramUserHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import MarketKit | ||
import ObjectMapper | ||
import RxSwift | ||
import UIKit | ||
|
||
class TelegramUserHandler { | ||
private let disposeBag = DisposeBag() | ||
private let parentViewController: UIViewController? | ||
private let marketKit = App.shared.marketKit | ||
private let baseUrl = AppConfig.referralAppServerUrl | ||
|
||
init(parentViewController: UIViewController?) { | ||
self.parentViewController = parentViewController | ||
} | ||
} | ||
|
||
extension TelegramUserHandler: IEventHandler { | ||
@MainActor | ||
func handle(source: StatPage, event: Any, eventType: EventHandler.EventType) async throws { | ||
if eventType.contains(.deepLink), let event = event as? DeepLinkManager.DeepLink { | ||
guard case let .referral(userId, referralCode) = event else { | ||
throw EventHandler.HandleError.noSuitableHandler | ||
} | ||
let urlString = "\(baseUrl)/v1/tasks/registerApp?userId=\(userId)&referralCode=\(referralCode)" | ||
print("Requesting: \(urlString)") | ||
guard let url = URL(string: urlString) else { | ||
return | ||
} | ||
|
||
let _: EmptyResponse = try await App.shared.networkManager.fetch(url: url) | ||
} | ||
} | ||
} | ||
|
||
extension TelegramUserHandler { | ||
static func handler(parentViewController: UIViewController? = nil) -> IEventHandler { | ||
TelegramUserHandler(parentViewController: parentViewController) | ||
} | ||
} | ||
|
||
struct EmptyResponse: ImmutableMappable { | ||
init(map: Map) throws {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
UnstoppableWallet/UnstoppableWallet/Modules/Welcome/WelcomeScreenViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class WelcomeScreenViewModel { | ||
private let deepLinkService: DeepLinkService | ||
private let eventHandler: EventHandler | ||
|
||
init(deepLinkService: DeepLinkService, eventHandler: EventHandler) { | ||
self.deepLinkService = deepLinkService | ||
self.eventHandler = eventHandler | ||
} | ||
|
||
func handleDeepLink() { | ||
guard let deepLink = deepLinkService.deepLink else { | ||
return | ||
} | ||
|
||
Task { | ||
do { | ||
try await eventHandler.handle(source: .main, event: deepLink, eventType: .deepLink) | ||
deepLinkService.setDeepLinkShown() | ||
} catch { | ||
print("Can't handle Deep Link \(error)") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.