Various fixes

This commit is contained in:
Ilya Laktyushin 2025-06-28 23:51:09 +02:00
parent df3eab0a74
commit 2ce6d8c66c
5 changed files with 27 additions and 13 deletions

View File

@ -232,7 +232,7 @@ final class ComposePollScreenComponent: Component {
}
private func item(at point: CGPoint) -> (AnyHashable, ComponentView<Empty>)? {
if self.scrollView.isTracking || self.scrollView.isDecelerating {
if self.scrollView.isDragging || self.scrollView.isDecelerating {
return nil
}
@ -240,7 +240,7 @@ final class ComposePollScreenComponent: Component {
for (id, itemView) in self.pollOptionsSectionContainer.itemViews {
if let view = itemView.contents.view as? ListComposePollOptionComponent.View, !view.isRevealed && !view.currentText.isEmpty {
let viewFrame = view.convert(view.bounds, to: self.pollOptionsSectionContainer)
let iconFrame = CGRect(origin: CGPoint(x: viewFrame.maxX - viewFrame.height, y: viewFrame.minY), size: CGSize(width: viewFrame.height, height: viewFrame.height))
let iconFrame = CGRect(origin: CGPoint(x: viewFrame.maxX - 40.0, y: viewFrame.minY), size: CGSize(width: viewFrame.height, height: viewFrame.height))
if iconFrame.contains(localPoint) {
return (id, itemView.contents)
}
@ -941,6 +941,11 @@ final class ComposePollScreenComponent: Component {
})
}
var canDelete = true
if i == self.pollOptions.count - 1 {
canDelete = false
}
pollOptionsSectionItems.append(AnyComponentWithIdentity(id: pollOption.id, component: AnyComponent(ListComposePollOptionComponent(
externalState: pollOption.textInputState,
context: component.context,
@ -1001,13 +1006,13 @@ final class ComposePollScreenComponent: Component {
}
self.state?.updated(transition: .spring(duration: 0.4))
},
deleteAction: { [weak self] in
deleteAction: canDelete ? { [weak self] in
guard let self else {
return
}
self.pollOptions.removeAll(where: { $0.id == optionId })
self.state?.updated(transition: .spring(duration: 0.4))
},
} : nil,
tag: pollOption.textFieldTag
))))

View File

@ -12,9 +12,10 @@ public struct StarsRevenueStats: Equatable, Codable {
case usdRate
}
static func key(peerId: PeerId) -> ValueBoxKey {
static func key(peerId: PeerId, ton: Bool) -> ValueBoxKey {
let key = ValueBoxKey(length: 8 + 4)
key.setInt64(0, value: peerId.toInt64())
key.setInt32(8, value: ton ? 1 : 0)
return key
}
@ -227,7 +228,7 @@ private final class StarsRevenueStatsContextImpl {
self.load()
let _ = (account.postbox.transaction { transaction -> StarsRevenueStats? in
return transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStarsRevenueStats, key: StarsRevenueStats.key(peerId: peerId)))?.get(StarsRevenueStats.self)
return transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStarsRevenueStats, key: StarsRevenueStats.key(peerId: peerId, ton: ton)))?.get(StarsRevenueStats.self)
}
|> deliverOnMainQueue).start(next: { [weak self] cachedResult in
guard let self, let cachedResult else {
@ -259,6 +260,7 @@ private final class StarsRevenueStatsContextImpl {
let account = self.account
let peerId = self.peerId
let ton = self.ton
let signal = requestStarsRevenueStats(postbox: self.account.postbox, network: self.account.network, peerId: self.peerId, ton: self.ton)
|> mapToSignal { initial -> Signal<StarsRevenueStats?, NoError> in
guard let initial else {
@ -285,7 +287,7 @@ private final class StarsRevenueStatsContextImpl {
if let stats {
let _ = (self.account.postbox.transaction { transaction in
if let entry = CodableEntry(stats) {
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStarsRevenueStats, key: StarsRevenueStats.key(peerId: peerId)), entry: entry)
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStarsRevenueStats, key: StarsRevenueStats.key(peerId: peerId, ton: ton)), entry: entry)
}
}).start()
}

View File

@ -180,7 +180,7 @@ final class ComposeTodoScreenComponent: Component {
}
private func item(at point: CGPoint) -> (AnyHashable, ComponentView<Empty>)? {
if self.scrollView.isTracking || self.scrollView.isDecelerating {
if self.scrollView.isDragging || self.scrollView.isDecelerating {
return nil
}
@ -188,7 +188,7 @@ final class ComposeTodoScreenComponent: Component {
for (id, itemView) in self.todoItemsSectionContainer.itemViews {
if let view = itemView.contents.view as? ListComposePollOptionComponent.View, !view.isRevealed && !view.currentText.isEmpty {
let viewFrame = view.convert(view.bounds, to: self.todoItemsSectionContainer)
let iconFrame = CGRect(origin: CGPoint(x: viewFrame.maxX - viewFrame.height, y: viewFrame.minY), size: CGSize(width: viewFrame.height, height: viewFrame.height))
let iconFrame = CGRect(origin: CGPoint(x: viewFrame.maxX - 40.0, y: viewFrame.minY), size: CGSize(width: viewFrame.height, height: viewFrame.height))
if iconFrame.contains(localPoint) {
return (id, itemView.contents)
}
@ -861,6 +861,11 @@ final class ComposeTodoScreenComponent: Component {
isEnabled = false
}
var canDelete = isEnabled
if i == self.todoItems.count - 1 {
canDelete = false
}
todoItemsSectionItems.append(AnyComponentWithIdentity(id: todoItem.id, component: AnyComponent(ListComposePollOptionComponent(
externalState: todoItem.textInputState,
context: component.context,
@ -922,7 +927,7 @@ final class ComposeTodoScreenComponent: Component {
}
self.state?.updated(transition: .spring(duration: 0.4))
},
deleteAction: isEnabled ? { [weak self] in
deleteAction: canDelete ? { [weak self] in
guard let self else {
return
}

View File

@ -459,9 +459,6 @@ public final class ListComposePollOptionComponent: Component {
return false
}
}
if gestureRecognizer == self.recognizer, let externalState = self.component?.externalState, !externalState.hasText {
return false
}
return true
}
@ -566,6 +563,10 @@ public final class ListComposePollOptionComponent: Component {
rightInset += 34.0
}
if component.canReorder {
rightInset += 16.0
}
let textFieldSize = self.textField.update(
transition: transition,
component: AnyComponent(TextFieldComponent(

View File

@ -75,6 +75,7 @@ extension ChatControllerImpl {
}
} else if peer is TelegramSecretChat {
canSendPolls = false
canSendTodos = false
} else if let channel = peer as? TelegramChannel {
if case .broadcast = channel.info {
canSendTodos = false