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>)? { 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 return nil
} }
@ -240,7 +240,7 @@ final class ComposePollScreenComponent: Component {
for (id, itemView) in self.pollOptionsSectionContainer.itemViews { for (id, itemView) in self.pollOptionsSectionContainer.itemViews {
if let view = itemView.contents.view as? ListComposePollOptionComponent.View, !view.isRevealed && !view.currentText.isEmpty { if let view = itemView.contents.view as? ListComposePollOptionComponent.View, !view.isRevealed && !view.currentText.isEmpty {
let viewFrame = view.convert(view.bounds, to: self.pollOptionsSectionContainer) 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) { if iconFrame.contains(localPoint) {
return (id, itemView.contents) 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( pollOptionsSectionItems.append(AnyComponentWithIdentity(id: pollOption.id, component: AnyComponent(ListComposePollOptionComponent(
externalState: pollOption.textInputState, externalState: pollOption.textInputState,
context: component.context, context: component.context,
@ -1001,13 +1006,13 @@ final class ComposePollScreenComponent: Component {
} }
self.state?.updated(transition: .spring(duration: 0.4)) self.state?.updated(transition: .spring(duration: 0.4))
}, },
deleteAction: { [weak self] in deleteAction: canDelete ? { [weak self] in
guard let self else { guard let self else {
return return
} }
self.pollOptions.removeAll(where: { $0.id == optionId }) self.pollOptions.removeAll(where: { $0.id == optionId })
self.state?.updated(transition: .spring(duration: 0.4)) self.state?.updated(transition: .spring(duration: 0.4))
}, } : nil,
tag: pollOption.textFieldTag tag: pollOption.textFieldTag
)))) ))))

View File

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

View File

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

View File

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

View File

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