Skip to content

Commit 29b266d

Browse files
committed
Merge commit '3c61b4a1e4fccdc826f7013c9b166ee5768ae5c0' into beta
2 parents e2cd4a5 + 3c61b4a commit 29b266d

File tree

8 files changed

+135
-11
lines changed

8 files changed

+135
-11
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal:
2727
- rm -rf build-input/configuration-repository
2828
- python3 -u build-system/Make/Make.py remote-build --darwinContainers="$DARWIN_CONTAINERS" --darwinContainersHost="$DARWIN_CONTAINERS_HOST" --cacheHost="$TELEGRAM_BAZEL_CACHE_HOST" --configurationPath="$TELEGRAM_PRIVATE_DATA_PATH/build-configurations/enterprise-configuration.json" --gitCodesigningRepository="$TELEGRAM_GIT_CODESIGNING_REPOSITORY" --gitCodesigningType=enterprise --configuration=release_arm64
2929
- python3 -u build-system/Make/DeployToFirebase.py --configuration="$TELEGRAM_PRIVATE_DATA_PATH/firebase-configurations/firebase-enterprise.json" --ipa="build/artifacts/Telegram.ipa" --dsyms="build/artifacts/Telegram.DSYMs.zip"
30+
- python3 -u build-system/Make/DeployBuild.py --configuration="$TELEGRAM_PRIVATE_DATA_PATH/deploy-configurations/enterprise-configuration.json" --ipa="build/artifacts/Telegram.ipa" --dsyms="build/artifacts/Telegram.DSYMs.zip"
3031
environment:
3132
name: internal
3233
artifacts:

build-system/Make/DeployBuild.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/bin/python3
2+
3+
import argparse
4+
import os
5+
import sys
6+
import json
7+
import hashlib
8+
import base64
9+
import requests
10+
11+
def sha256_file(path):
12+
h = hashlib.sha256()
13+
with open(path, 'rb') as f:
14+
while True:
15+
data = f.read(1024 * 64)
16+
if not data:
17+
break
18+
h.update(data)
19+
return h.hexdigest()
20+
21+
def init_build(host, token, files):
22+
url = host.rstrip('/') + '/upload/init'
23+
headers = {"Authorization": "Bearer " + token}
24+
payload = {"files": files}
25+
r = requests.post(url, json=payload, headers=headers, timeout=30)
26+
r.raise_for_status()
27+
return r.json()
28+
29+
def upload_file(path, upload_info):
30+
url = upload_info.get('url')
31+
headers = dict(upload_info.get('headers', {}))
32+
33+
size = os.path.getsize(path)
34+
headers['Content-Length'] = str(size)
35+
36+
print('Uploading', path)
37+
with open(path, 'rb') as f:
38+
r = requests.put(url, data=f, headers=headers, timeout=900)
39+
if r.status_code != 200:
40+
print('Upload failed', r.status_code)
41+
print(r.text[:500])
42+
r.raise_for_status()
43+
44+
def commit_build(host, token, build_id):
45+
url = host.rstrip('/') + '/upload/commit'
46+
headers = {"Authorization": "Bearer " + token}
47+
r = requests.post(url, json={"buildId": build_id}, headers=headers, timeout=900)
48+
if r.status_code != 200:
49+
print('Commit failed', r.status_code)
50+
print(r.text[:500])
51+
r.raise_for_status()
52+
return r.json()
53+
54+
if __name__ == '__main__':
55+
parser = argparse.ArgumentParser(prog='deploy-build')
56+
parser.add_argument('--ipa', required=True, help='Path to IPA')
57+
parser.add_argument('--dsyms', help='Path to dSYMs.zip')
58+
parser.add_argument('--configuration', required=True, help='Path to JSON config')
59+
args = parser.parse_args()
60+
61+
if not os.path.exists(args.configuration):
62+
print('{} does not exist'.format(args.configuration))
63+
sys.exit(1)
64+
if not os.path.exists(args.ipa):
65+
print('{} does not exist'.format(args.ipa))
66+
sys.exit(1)
67+
if args.dsyms is not None and not os.path.exists(args.dsyms):
68+
print('{} does not exist'.format(args.dsyms))
69+
sys.exit(1)
70+
71+
try:
72+
with open(args.configuration, 'r') as f:
73+
config = json.load(f)
74+
except Exception as e:
75+
print('Failed to read configuration:', e)
76+
sys.exit(1)
77+
78+
host = config.get('host')
79+
token = config.get('auth_token')
80+
if not host or not token:
81+
print('Invalid configuration')
82+
sys.exit(1)
83+
ipa_path = args.ipa
84+
dsym_path = args.dsyms
85+
86+
ipa_sha = sha256_file(ipa_path)
87+
files = {
88+
'ipa': {
89+
'filename': os.path.basename(ipa_path),
90+
'size': os.path.getsize(ipa_path),
91+
'sha256': ipa_sha,
92+
}
93+
}
94+
if dsym_path:
95+
dsym_sha = sha256_file(dsym_path)
96+
files['dsym'] = {
97+
'filename': os.path.basename(dsym_path),
98+
'size': os.path.getsize(dsym_path),
99+
'sha256': dsym_sha,
100+
}
101+
102+
print('Init build')
103+
init = init_build(host, token, files)
104+
build_id = init.get('build_id')
105+
urls = init.get('upload_urls', {})
106+
if not build_id:
107+
print('No build_id')
108+
sys.exit(1)
109+
110+
upload_file(ipa_path, urls.get('ipa', {}))
111+
if dsym_path and 'dsym' in urls:
112+
upload_file(dsym_path, urls.get('dsym', {}))
113+
114+
print('Commit build')
115+
result = commit_build(host, token, build_id)
116+
117+
print('Done! Install page:', result.get('install_page_url'))

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func _internal_keepCachedStarGiftsUpdated(postbox: Postbox, network: Network, ac
976976
let updateSignal = _internal_cachedStarGifts(postbox: postbox)
977977
|> take(1)
978978
|> mapToSignal { list -> Signal<Never, NoError> in
979-
return network.request(Api.functions.payments.getStarGifts(hash: 0))
979+
return network.request(Api.functions.payments.getStarGifts(hash: list?.hashValue ?? 0))
980980
|> map(Optional.init)
981981
|> `catch` { _ -> Signal<Api.payments.StarGifts?, NoError> in
982982
return .single(nil)

submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ final class GiftSetupScreenComponent: Component {
124124

125125
private var inProgress = false
126126

127-
128127
private var previousHadInputHeight: Bool = false
129128
private var previousInputHeight: CGFloat?
130129
private var recenterOnTag: NSObject?
@@ -134,6 +133,8 @@ final class GiftSetupScreenComponent: Component {
134133

135134
private var starImage: (UIImage, PresentationTheme)?
136135

136+
private var updateDisposable: Disposable?
137+
137138
private var optionsDisposable: Disposable?
138139
private(set) var options: [StarsTopUpOption] = [] {
139140
didSet {
@@ -173,6 +174,9 @@ final class GiftSetupScreenComponent: Component {
173174
}
174175

175176
deinit {
177+
self.inputMediaNodeDataDisposable?.dispose()
178+
self.updateDisposable?.dispose()
179+
self.optionsDisposable?.dispose()
176180
}
177181

178182
func scrollToTop() {

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ private final class GiftViewSheetContent: CombinedComponent {
931931
})
932932

933933
if let tranfserGiftImpl {
934-
return tranfserGiftImpl(transferStars == 0, peerId)
934+
return tranfserGiftImpl(transferStars == 0, reference, peerId)
935935
} else {
936936
return (context.engine.payments.transferStarGift(prepaid: transferStars == 0, reference: reference, peerId: peerId)
937937
|> deliverOnMainQueue)
@@ -4554,7 +4554,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
45544554

45554555
fileprivate let updateSavedToProfile: ((StarGiftReference, Bool) -> Void)?
45564556
fileprivate let convertToStars: ((StarGiftReference) -> Void)?
4557-
fileprivate let transferGift: ((Bool, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)?
4557+
fileprivate let transferGift: ((Bool, StarGiftReference, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)?
45584558
fileprivate let upgradeGift: ((Int64?, StarGiftReference, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)?
45594559
fileprivate let buyGift: ((String, EnginePeer.Id, CurrencyAmount?) -> Signal<Never, BuyStarGiftError>)?
45604560
fileprivate let updateResellStars: ((StarGiftReference, CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)?
@@ -4572,7 +4572,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
45724572
forceDark: Bool = false,
45734573
updateSavedToProfile: ((StarGiftReference, Bool) -> Void)? = nil,
45744574
convertToStars: ((StarGiftReference) -> Void)? = nil,
4575-
transferGift: ((Bool, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)? = nil,
4575+
transferGift: ((Bool, StarGiftReference, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)? = nil,
45764576
upgradeGift: ((Int64?, StarGiftReference, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil,
45774577
buyGift: ((String, EnginePeer.Id, CurrencyAmount?) -> Signal<Never, BuyStarGiftError>)? = nil,
45784578
updateResellStars: ((StarGiftReference, CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)? = nil,

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
19051905
transition.updateFrameAdditive(node: self.avatarListNode, frame: CGRect(origin: apparentAvatarFrame.center, size: CGSize()))
19061906
transition.updateFrameAdditive(node: self.avatarOverlayNode, frame: CGRect(origin: apparentAvatarFrame.center, size: CGSize()))
19071907

1908-
let avatarListContainerFrame: CGRect
1908+
var avatarListContainerFrame: CGRect
19091909
let avatarListContainerScale: CGFloat
19101910
if self.isAvatarExpanded {
19111911
if let transitionSourceAvatarFrame = transitionSourceAvatarFrame {
@@ -1922,6 +1922,8 @@ final class PeerInfoHeaderNode: ASDisplayNode {
19221922
avatarListContainerFrame = CGRect(origin: CGPoint(x: -expandedAvatarListSize.width / 2.0, y: -expandedAvatarListSize.width / 2.0), size: expandedAvatarListSize)
19231923
}
19241924
avatarListContainerScale = 1.0 + max(0.0, -contentOffset / avatarListContainerFrame.width)
1925+
let heightDelta = avatarListContainerFrame.height * avatarListContainerScale - avatarListContainerFrame.height
1926+
avatarListContainerFrame.origin.y -= heightDelta / 4.0
19251927
} else {
19261928
let expandHeightFraction = expandedAvatarListSize.height / expandedAvatarListSize.width
19271929
avatarListContainerFrame = CGRect(origin: CGPoint(x: -apparentAvatarFrame.width / 2.0, y: -apparentAvatarFrame.width / 2.0 + expandHeightFraction * 0.0 * apparentAvatarFrame.width), size: apparentAvatarFrame.size)

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,8 +5018,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
50185018
}
50195019
profileGifts.convertStarGift(reference: reference)
50205020
},
5021-
transferGift: { [weak profileGifts] prepaid, peerId in
5022-
guard let profileGifts, let reference = gift.reference else {
5021+
transferGift: { [weak profileGifts] prepaid, reference, peerId in
5022+
guard let profileGifts else {
50235023
return .complete()
50245024
}
50255025
return profileGifts.transferStarGift(prepaid: prepaid, reference: reference, peerId: peerId)

submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ final class GiftsListView: UIView {
502502
peer = nil
503503
resellAmount = gift.resellAmounts?.first(where: { $0.currency == .stars })
504504

505-
if let _ = resellAmount {
505+
if !(gift.resellAmounts ?? []).isEmpty {
506506
ribbonText = params.presentationData.strings.PeerInfo_Gifts_Sale
507507
ribbonFont = .larger
508508
ribbonColor = .green
@@ -617,8 +617,8 @@ final class GiftsListView: UIView {
617617
}
618618
self.profileGifts.convertStarGift(reference: reference)
619619
},
620-
transferGift: { [weak self] prepaid, peerId in
621-
guard let self, let reference = product.reference else {
620+
transferGift: { [weak self] prepaid, reference, peerId in
621+
guard let self else {
622622
return .complete()
623623
}
624624
return self.profileGifts.transferStarGift(prepaid: prepaid, reference: reference, peerId: peerId)

0 commit comments

Comments
 (0)