mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 11:25:38 +00:00
Fix close poll appearance
This commit is contained in:
parent
9f2c27072c
commit
49d76ffce7
@ -614,7 +614,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
}
|
||||
totalVoterCount = totalVoters
|
||||
if didVote {
|
||||
if didVote || poll.isClosed {
|
||||
for i in 0 ..< poll.options.count {
|
||||
inner: for optionVoters in voters {
|
||||
if optionVoters.opaqueIdentifier == poll.options[i].opaqueIdentifier {
|
||||
|
||||
@ -348,12 +348,12 @@ class CreatePollOptionItemNode: ItemListRevealOptionsItemNode, ItemListItemNode,
|
||||
let editableControlFrame = CGRect(origin: CGPoint(x: params.leftInset + 6.0 + revealOffset, y: 0.0), size: controlSizeAndApply.0)
|
||||
strongSelf.editableControlNode.frame = editableControlFrame
|
||||
|
||||
let _ = reorderSizeAndApply.1(displayTextLimit)
|
||||
let _ = reorderSizeAndApply.1(displayTextLimit && layout.contentSize.height <= 44.0)
|
||||
let reorderControlFrame = CGRect(origin: CGPoint(x: params.width + revealOffset - params.rightInset - reorderSizeAndApply.0.width, y: 0.0), size: reorderSizeAndApply.0)
|
||||
strongSelf.reorderControlNode.frame = reorderControlFrame
|
||||
|
||||
let _ = textLimitApply()
|
||||
strongSelf.textLimitNode.frame = CGRect(origin: CGPoint(x: reorderControlFrame.minX + floor((reorderControlFrame.width - textLimitLayout.size.width) / 2.0) - 4.0 - UIScreenPixel, y: floor(reorderControlFrame.midY + 2.0)), size: textLimitLayout.size)
|
||||
strongSelf.textLimitNode.frame = CGRect(origin: CGPoint(x: reorderControlFrame.minX + floor((reorderControlFrame.width - textLimitLayout.size.width) / 2.0) - 4.0 - UIScreenPixel, y: max(floor(reorderControlFrame.midY + 2.0), layout.contentSize.height - 15.0 - textLimitLayout.size.height)), size: textLimitLayout.size)
|
||||
strongSelf.textLimitNode.isHidden = !displayTextLimit
|
||||
|
||||
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
|
||||
|
||||
@ -17,6 +17,7 @@ public enum MessageContentKindKey {
|
||||
case liveLocation
|
||||
case expiredImage
|
||||
case expiredVideo
|
||||
case poll
|
||||
}
|
||||
|
||||
public enum MessageContentKind: Equatable {
|
||||
@ -34,6 +35,7 @@ public enum MessageContentKind: Equatable {
|
||||
case liveLocation
|
||||
case expiredImage
|
||||
case expiredVideo
|
||||
case poll(String)
|
||||
|
||||
public var key: MessageContentKindKey {
|
||||
switch self {
|
||||
@ -65,6 +67,8 @@ public enum MessageContentKind: Equatable {
|
||||
return .expiredImage
|
||||
case .expiredVideo:
|
||||
return .expiredVideo
|
||||
case .poll:
|
||||
return .poll
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,10 +86,10 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
|
||||
switch media {
|
||||
case let expiredMedia as TelegramMediaExpiredContent:
|
||||
switch expiredMedia.data {
|
||||
case .image:
|
||||
return .expiredImage
|
||||
case .file:
|
||||
return .expiredVideo
|
||||
case .image:
|
||||
return .expiredImage
|
||||
case .file:
|
||||
return .expiredVideo
|
||||
}
|
||||
case _ as TelegramMediaImage:
|
||||
return .image
|
||||
@ -93,34 +97,34 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
|
||||
var fileName: String = ""
|
||||
for attribute in file.attributes {
|
||||
switch attribute {
|
||||
case let .Sticker(text, _, _):
|
||||
return .sticker(text)
|
||||
case let .FileName(name):
|
||||
fileName = name
|
||||
case let .Audio(isVoice, _, title, performer, _):
|
||||
if isVoice {
|
||||
return .audioMessage
|
||||
} else {
|
||||
if let title = title, let performer = performer, !title.isEmpty, !performer.isEmpty {
|
||||
return .file(title + " — " + performer)
|
||||
} else if let title = title, !title.isEmpty {
|
||||
return .file(title)
|
||||
} else if let performer = performer, !performer.isEmpty {
|
||||
return .file(performer)
|
||||
}
|
||||
}
|
||||
case let .Video(_, _, flags):
|
||||
if file.isAnimated {
|
||||
return .animation
|
||||
} else {
|
||||
if flags.contains(.instantRoundVideo) {
|
||||
return .videoMessage
|
||||
case let .Sticker(text, _, _):
|
||||
return .sticker(text)
|
||||
case let .FileName(name):
|
||||
fileName = name
|
||||
case let .Audio(isVoice, _, title, performer, _):
|
||||
if isVoice {
|
||||
return .audioMessage
|
||||
} else {
|
||||
return .video
|
||||
if let title = title, let performer = performer, !title.isEmpty, !performer.isEmpty {
|
||||
return .file(title + " — " + performer)
|
||||
} else if let title = title, !title.isEmpty {
|
||||
return .file(title)
|
||||
} else if let performer = performer, !performer.isEmpty {
|
||||
return .file(performer)
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
case let .Video(_, _, flags):
|
||||
if file.isAnimated {
|
||||
return .animation
|
||||
} else {
|
||||
if flags.contains(.instantRoundVideo) {
|
||||
return .videoMessage
|
||||
} else {
|
||||
return .video
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return .file(fileName)
|
||||
@ -141,7 +145,7 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
|
||||
return nil
|
||||
}
|
||||
case let poll as TelegramMediaPoll:
|
||||
return .text(poll.text)
|
||||
return .poll(poll.text)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -185,6 +189,8 @@ func stringForMediaKind(_ kind: MessageContentKind, strings: PresentationStrings
|
||||
return (strings.Message_ImageExpired, true)
|
||||
case .expiredVideo:
|
||||
return (strings.Message_VideoExpired, true)
|
||||
case let .poll(text):
|
||||
return ("📊 \(text)", false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user