Skip to content

Commit 865cebe

Browse files
author
Isaac
committed
Levels
1 parent 6ff5012 commit 865cebe

File tree

13 files changed

+948
-49
lines changed

13 files changed

+948
-49
lines changed

MODULE.bazel.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5122,8 +5122,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
51225122
var price: Int?
51235123

51245124
if let globalPostSearchStateValue = self.globalPostSearchStateValue, globalPostSearchStateValue.remainingFreeSearches == 0 {
5125-
//TODO:localize
5126-
price = 10
5125+
price = Int(globalPostSearchStateValue.price.value)
51275126
}
51285127

51295128
self.approvedGlobalPostQueryState.set(ApprovedGlobalPostQueryState(
@@ -5419,7 +5418,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
54195418
emptyResultsButtonContent = .searchQuery(query)
54205419
} else {
54215420
emptyResultsTitle = "Limit Reached"
5422-
emptyResultsText = "You can make up to\n10 search queries per day."
5421+
emptyResultsText = "You can make up to\n\(globalSearchStateValue.totalFreeSearches) search queries per day."
54235422

54245423
emptyResultsButtonContent = .paidSearch(
54255424
price: Int(globalSearchStateValue.price.value),

submodules/Postbox/Sources/Postbox.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ public func openPostbox(basePath: String, seedConfiguration: SeedConfiguration,
14621462

14631463
#if DEBUG
14641464
//debugSaveState(basePath: basePath + "/db", name: "previous2")
1465-
debugRestoreState(basePath: basePath + "/db", name: "previous2")
1465+
//debugRestoreState(basePath: basePath + "/db", name: "previous2")
14661466
#endif
14671467

14681468
let startTime = CFAbsoluteTimeGetCurrent()

submodules/TelegramApi/Sources/Api0.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
881881
dict[-1115174036] = { return Api.SavedDialog.parse_savedDialog($0) }
882882
dict[-881854424] = { return Api.SavedReactionTag.parse_savedReactionTag($0) }
883883
dict[514213599] = { return Api.SavedStarGift.parse_savedStarGift($0) }
884-
dict[-1810993028] = { return Api.SearchPostsFlood.parse_searchPostsFlood($0) }
884+
dict[1040931690] = { return Api.SearchPostsFlood.parse_searchPostsFlood($0) }
885885
dict[-911191137] = { return Api.SearchResultsCalendarPeriod.parse_searchResultsCalendarPeriod($0) }
886886
dict[2137295719] = { return Api.SearchResultsPosition.parse_searchResultPosition($0) }
887887
dict[871426631] = { return Api.SecureCredentialsEncrypted.parse_secureCredentialsEncrypted($0) }

submodules/TelegramApi/Sources/Api23.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,26 +296,27 @@ public extension Api {
296296
}
297297
public extension Api {
298298
enum SearchPostsFlood: TypeConstructorDescription {
299-
case searchPostsFlood(flags: Int32, remains: Int32, waitTill: Int32?, starsAmount: Int64)
299+
case searchPostsFlood(flags: Int32, totalDaily: Int32, remains: Int32, waitTill: Int32?, starsAmount: Int64)
300300

301301
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
302302
switch self {
303-
case .searchPostsFlood(let flags, let remains, let waitTill, let starsAmount):
303+
case .searchPostsFlood(let flags, let totalDaily, let remains, let waitTill, let starsAmount):
304304
if boxed {
305-
buffer.appendInt32(-1810993028)
305+
buffer.appendInt32(1040931690)
306306
}
307307
serializeInt32(flags, buffer: buffer, boxed: false)
308+
serializeInt32(totalDaily, buffer: buffer, boxed: false)
308309
serializeInt32(remains, buffer: buffer, boxed: false)
309-
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(waitTill!, buffer: buffer, boxed: false)}
310+
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(waitTill!, buffer: buffer, boxed: false)}
310311
serializeInt64(starsAmount, buffer: buffer, boxed: false)
311312
break
312313
}
313314
}
314315

315316
public func descriptionFields() -> (String, [(String, Any)]) {
316317
switch self {
317-
case .searchPostsFlood(let flags, let remains, let waitTill, let starsAmount):
318-
return ("searchPostsFlood", [("flags", flags as Any), ("remains", remains as Any), ("waitTill", waitTill as Any), ("starsAmount", starsAmount as Any)])
318+
case .searchPostsFlood(let flags, let totalDaily, let remains, let waitTill, let starsAmount):
319+
return ("searchPostsFlood", [("flags", flags as Any), ("totalDaily", totalDaily as Any), ("remains", remains as Any), ("waitTill", waitTill as Any), ("starsAmount", starsAmount as Any)])
319320
}
320321
}
321322

@@ -325,15 +326,18 @@ public extension Api {
325326
var _2: Int32?
326327
_2 = reader.readInt32()
327328
var _3: Int32?
328-
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
329-
var _4: Int64?
330-
_4 = reader.readInt64()
329+
_3 = reader.readInt32()
330+
var _4: Int32?
331+
if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() }
332+
var _5: Int64?
333+
_5 = reader.readInt64()
331334
let _c1 = _1 != nil
332335
let _c2 = _2 != nil
333-
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
334-
let _c4 = _4 != nil
335-
if _c1 && _c2 && _c3 && _c4 {
336-
return Api.SearchPostsFlood.searchPostsFlood(flags: _1!, remains: _2!, waitTill: _3, starsAmount: _4!)
336+
let _c3 = _3 != nil
337+
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
338+
let _c5 = _5 != nil
339+
if _c1 && _c2 && _c3 && _c4 && _c5 {
340+
return Api.SearchPostsFlood.searchPostsFlood(flags: _1!, totalDaily: _2!, remains: _3!, waitTill: _4, starsAmount: _5!)
337341
}
338342
else {
339343
return nil

submodules/TelegramApi/Sources/Api39.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,11 +2757,12 @@ public extension Api.functions.bots {
27572757
}
27582758
}
27592759
public extension Api.functions.channels {
2760-
static func checkSearchPostsFlood() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.SearchPostsFlood>) {
2760+
static func checkSearchPostsFlood(flags: Int32, query: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.SearchPostsFlood>) {
27612761
let buffer = Buffer()
2762-
buffer.appendInt32(-1146490591)
2763-
2764-
return (FunctionDescription(name: "channels.checkSearchPostsFlood", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.SearchPostsFlood? in
2762+
buffer.appendInt32(576090389)
2763+
serializeInt32(flags, buffer: buffer, boxed: false)
2764+
if Int(flags) & Int(1 << 0) != 0 {serializeString(query!, buffer: buffer, boxed: false)}
2765+
return (FunctionDescription(name: "channels.checkSearchPostsFlood", parameters: [("flags", String(describing: flags)), ("query", String(describing: query))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.SearchPostsFlood? in
27652766
let reader = BufferReader(buffer)
27662767
var result: Api.SearchPostsFlood?
27672768
if let signature = reader.readInt32() {

submodules/TelegramCore/Sources/TelegramEngine/Messages/SearchMessages.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,9 @@ func _internal_searchMessages(account: Account, location: SearchMessagesLocation
608608
if let searchFlood {
609609
transaction.updatePreferencesEntry(key: PreferencesKeys.globalPostSearchState(), { _ in
610610
switch searchFlood {
611-
case let .searchPostsFlood(_, remains, waitTill, starsAmount):
611+
case let .searchPostsFlood(_, totalDaily, remains, waitTill, starsAmount):
612612
return PreferencesEntry(TelegramGlobalPostSearchState(
613+
totalFreeSearches: totalDaily,
613614
remainingFreeSearches: remains,
614615
price: StarsAmount(value: starsAmount, nanos: 0),
615616
unlockTimestamp: waitTill
@@ -1089,7 +1090,7 @@ func _internal_updatedRemotePeer(accountPeerId: PeerId, postbox: Postbox, networ
10891090
}
10901091

10911092
func _internal_refreshGlobalPostSearchState(account: Account) -> Signal<Never, NoError> {
1092-
return account.network.request(Api.functions.channels.checkSearchPostsFlood())
1093+
return account.network.request(Api.functions.channels.checkSearchPostsFlood(flags: 0, query: nil))
10931094
|> map(Optional.init)
10941095
|> `catch` { _ -> Signal<Api.SearchPostsFlood?, NoError> in
10951096
return .single(nil)
@@ -1101,8 +1102,9 @@ func _internal_refreshGlobalPostSearchState(account: Account) -> Signal<Never, N
11011102
}
11021103
transaction.updatePreferencesEntry(key: PreferencesKeys.globalPostSearchState(), { _ in
11031104
switch result {
1104-
case let .searchPostsFlood(_, remains, waitTill, starsAmount):
1105+
case let .searchPostsFlood(_, totalDaily, remains, waitTill, starsAmount):
11051106
return PreferencesEntry(TelegramGlobalPostSearchState(
1107+
totalFreeSearches: totalDaily,
11061108
remainingFreeSearches: remains,
11071109
price: StarsAmount(value: starsAmount, nanos: 0),
11081110
unlockTimestamp: waitTill

submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,22 @@ public final class StoryPreloadInfo {
3838
}
3939

4040
public final class TelegramGlobalPostSearchState: Codable, Equatable {
41+
public let totalFreeSearches: Int32
4142
public let remainingFreeSearches: Int32
4243
public let price: StarsAmount
4344
public let unlockTimestamp: Int32?
4445

45-
public init(remainingFreeSearches: Int32, price: StarsAmount, unlockTimestamp: Int32?) {
46+
public init(totalFreeSearches: Int32, remainingFreeSearches: Int32, price: StarsAmount, unlockTimestamp: Int32?) {
47+
self.totalFreeSearches = totalFreeSearches
4648
self.remainingFreeSearches = remainingFreeSearches
4749
self.price = price
4850
self.unlockTimestamp = unlockTimestamp
4951
}
5052

5153
public static func ==(lhs: TelegramGlobalPostSearchState, rhs: TelegramGlobalPostSearchState) -> Bool {
54+
if lhs.totalFreeSearches != rhs.totalFreeSearches {
55+
return false
56+
}
5257
if lhs.remainingFreeSearches != rhs.remainingFreeSearches {
5358
return false
5459
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public final class PeerInfoRatingComponent: Component {
5656
private let borderLayer: SimpleLayer
5757
private let backgroundLayer: SimpleLayer
5858

59-
private var tempLevel: Int = 1
59+
//private var tempLevel: Int = 1
6060

6161
private var component: PeerInfoRatingComponent?
6262
private weak var state: EmptyComponentState?
@@ -81,15 +81,15 @@ public final class PeerInfoRatingComponent: Component {
8181
if case .ended = recognizer.state {
8282
self.component?.action()
8383

84-
if self.tempLevel < 10 {
84+
/*if self.tempLevel < 10 {
8585
self.tempLevel += 1
8686
} else {
8787
self.tempLevel += 10
8888
}
8989
if self.tempLevel >= 110 {
9090
self.tempLevel = 1
9191
}
92-
self.state?.updated(transition: .immediate)
92+
self.state?.updated(transition: .immediate)*/
9393
}
9494
}
9595

@@ -102,9 +102,8 @@ public final class PeerInfoRatingComponent: Component {
102102
self.component = component
103103
self.state = state
104104

105-
//TODO:localize
106-
//let level = component.level
107-
let level = self.tempLevel
105+
let level = component.level
106+
//let level = self.tempLevel
108107

109108
let iconSize = CGSize(width: 26.0, height: 26.0)
110109

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ swift_library(
160160
"//submodules/TelegramUI/Components/GifVideoLayer",
161161
"//submodules/Components/HierarchyTrackingLayer",
162162
"//submodules/TelegramUI/Components/PeerInfo/PeerInfoRatingComponent",
163+
"//submodules/TelegramUI/Components/PeerInfo/ProfileLevelInfoScreen",
163164
],
164165
visibility = [
165166
"//visibility:public",

0 commit comments

Comments
 (0)