Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Jun 2, 2020
2 parents e8b87bf + 89bb22b commit a5f9d41
Show file tree
Hide file tree
Showing 43 changed files with 2,556 additions and 2,035 deletions.
3 changes: 3 additions & 0 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5521,3 +5521,6 @@ Any member of this group will be able to see messages in the channel.";

"Conversation.Timer.Title" = "Send With Timer";
"Conversation.Timer.Send" = "Send With Timer";

"Conversation.NoticeInvitedByInChannel" = "%@ invited you to this channel";
"Conversation.NoticeInvitedByInGroup" = "%@ invited you to this group";
2 changes: 1 addition & 1 deletion submodules/AccountContext/Sources/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public enum TextLinkItemActionType {
}

public enum TextLinkItem {
case url(String)
case url(url: String, concealed: Bool)
case mention(String)
case hashtag(String?, String)
}
Expand Down
12 changes: 6 additions & 6 deletions submodules/ChatListUI/Sources/Node/ChatListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
editingOffset = 0.0
}

let enableChatListPhotos = item.context.sharedContext.immediateExperimentalUISettings.chatListPhotos
let enableChatListPhotos = true

let avatarDiameter = min(60.0, floor(item.presentationData.fontSize.baseDisplaySize * 60.0 / 17.0))
let avatarLeftInset = 18.0 + avatarDiameter
Expand Down Expand Up @@ -1182,9 +1182,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {

var textCutout: TextNodeCutout?
if !textLeftCutout.isZero {
textCutout = TextNodeCutout(topLeft: CGSize(width: textLeftCutout, height: 4.0), topRight: nil, bottomRight: nil)
textCutout = TextNodeCutout(topLeft: CGSize(width: textLeftCutout, height: 10.0), topRight: nil, bottomRight: nil)
}
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: textAttributedString, backgroundColor: nil, maximumNumberOfLines: authorAttributedString == nil ? 2 : 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth - badgeSize, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: textCutout, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0)))
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: textAttributedString, backgroundColor: nil, maximumNumberOfLines: authorAttributedString == nil ? 2 : 1, truncationType: .end, constrainedSize: CGSize(width: rawContentWidth - badgeSize - textLeftCutout, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: textCutout, insets: UIEdgeInsets(top: 2.0, left: 1.0, bottom: 2.0, right: 1.0)))

let titleRectWidth = rawContentWidth - dateLayout.size.width - 10.0 - statusWidth - titleIconsWidth
let (titleLayout, titleApply) = titleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: titleRectWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
Expand Down Expand Up @@ -1287,7 +1287,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
}
let layout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: max(0.0, itemHeight + heightOffset)), insets: insets)

let contentImageSize = CGSize(width: 22.0, height: 22.0)
let contentImageSize = CGSize(width: 18.0, height: 18.0)

var customActions: [ChatListItemAccessibilityCustomAction] = []
for option in peerLeftRevealOptions {
Expand Down Expand Up @@ -1541,7 +1541,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.authorNode.frame = authorNodeFrame
let textNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x, y: contentRect.minY + titleLayout.size.height - 1.0 + UIScreenPixel + (authorLayout.size.height.isZero ? 0.0 : (authorLayout.size.height - 3.0))), size: textLayout.size)
strongSelf.textNode.frame = textNodeFrame
let contentImageFrame = CGRect(origin: textNodeFrame.origin.offsetBy(dx: 1.0, dy: 0.0), size: contentImageSize)
let contentImageFrame = CGRect(origin: textNodeFrame.origin.offsetBy(dx: 1.0, dy: 2.0), size: contentImageSize)
if contentImageNodeAppeared {
strongSelf.contentImageNode.frame = contentImageFrame
} else {
Expand Down Expand Up @@ -1750,7 +1750,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
transition.updateFrameAdditive(node: self.textNode, frame: textFrame)

var contentImageFrame = self.contentImageNode.frame
contentImageFrame.origin = textFrame.origin.offsetBy(dx: 1.0, dy: 0.0)
contentImageFrame.origin = textFrame.origin.offsetBy(dx: 1.0, dy: 2.0)
transition.updateFrame(node: self.contentImageNode, frame: contentImageFrame)

let dateFrame = self.dateNode.frame
Expand Down
18 changes: 10 additions & 8 deletions submodules/ChatListUI/Sources/TabBarChatListFilterController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
}

var count = 0
var hasUnmutedUnread = false
var unmutedUnreadCount = 0
if let totalState = totalStates[.root] {
for tag in tags {
if filter.data.excludeMuted {
if let value = totalState.filteredCounters[tag] {
if value.chatCount != 0 {
count += Int(value.chatCount)
hasUnmutedUnread = true
unmutedUnreadCount += Int(value.chatCount)
}
}
} else {
Expand All @@ -117,7 +117,7 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
}
if let value = totalState.filteredCounters[tag] {
if value.chatCount != 0 {
hasUnmutedUnread = true
unmutedUnreadCount += Int(value.chatCount)
}
}
}
Expand All @@ -130,7 +130,7 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
if let value = totalState.filteredCounters[tag] {
if value.chatCount != 0 {
count += Int(value.chatCount)
hasUnmutedUnread = true
unmutedUnreadCount += Int(value.chatCount)
}
}
} else {
Expand All @@ -139,7 +139,7 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
}
if let value = totalState.filteredCounters[tag] {
if value.chatCount != 0 {
hasUnmutedUnread = true
unmutedUnreadCount += Int(value.chatCount)
}
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
if matchesGroup && peerCount != 0 {
count += 1
if hasUnmuted {
hasUnmutedUnread = true
unmutedUnreadCount += 1
}
}
}
Expand All @@ -181,7 +181,6 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
var matches = true
if tags.contains(tag) {
if isMuted && filter.data.excludeMuted {
} else {
matches = false
}
}
Expand All @@ -200,11 +199,14 @@ func chatListFilterItems(postbox: Postbox) -> Signal<(Int, [(ChatListFilter, Int
}
if matchesGroup && peerCount != 0 {
count -= 1
if !isMuted {
unmutedUnreadCount -= 1
}
}
}
}
}
result.append((filter, max(0, count), hasUnmutedUnread))
result.append((filter, max(0, count), unmutedUnreadCount > 0))
}

return (totalBadge, result)
Expand Down
9 changes: 9 additions & 0 deletions submodules/Display/Source/ImmediateTextNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public class ImmediateTextNode: TextNode {
return ImmediateTextNodeLayoutInfo(size: layout.size, truncated: layout.truncated)
}

public func updateLayoutFullInfo(_ constrainedSize: CGSize) -> TextNodeLayout {
self.constrainedSize = constrainedSize

let makeLayout = TextNode.asyncLayout(self)
let (layout, apply) = makeLayout(TextNodeLayoutArguments(attributedString: self.attributedText, backgroundColor: nil, maximumNumberOfLines: self.maximumNumberOfLines, truncationType: self.truncationType, constrainedSize: constrainedSize, alignment: self.textAlignment, lineSpacing: self.lineSpacing, cutout: self.cutout, insets: self.insets))
let _ = apply()
return layout
}

public func redrawIfPossible() {
if let constrainedSize = self.constrainedSize {
let _ = self.updateLayout(constrainedSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public class ItemListMultilineTextItemNode: ListViewItemNode {
let textNodeFrame = self.textNode.frame
if let (_, attributes) = self.textNode.attributesAtPoint(CGPoint(x: point.x - textNodeFrame.minX, y: point.y - textNodeFrame.minY)) {
if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
return .url(url)
return .url(url: url, concealed: false)
} else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
return .mention(peerName)
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
let textNodeFrame = self.textNode.frame
if let (_, attributes) = self.textNode.attributesAtPoint(CGPoint(x: point.x - textNodeFrame.minX, y: point.y - textNodeFrame.minY)) {
if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
return .url(url)
return .url(url: url, concealed: false)
} else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
return .mention(peerName)
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
Expand Down
3 changes: 3 additions & 0 deletions submodules/LocationUI/Sources/LegacyLocationPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public func legacyLocationPickerController(context: AccountContext, selfPeer: Pe
return .single(nil)
}
return requestChatContextResults(account: context.account, botId: peerId, peerId: selfPeer.id, query: query ?? "", location: .single((location?.coordinate.latitude ?? 0.0, location?.coordinate.longitude ?? 0.0)), offset: "")
|> map { results -> ChatContextResultCollection? in
return results?.results
}
|> `catch` { error -> Signal<ChatContextResultCollection?, NoError> in
return .single(nil)
}
Expand Down
3 changes: 3 additions & 0 deletions submodules/LocationUI/Sources/LocationUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public func nearbyVenues(account: Account, latitude: Double, longitude: Double,
return .single(nil)
}
return requestChatContextResults(account: account, botId: peerId, peerId: account.peerId, query: query ?? "", location: .single((latitude, longitude)), offset: "")
|> map { results -> ChatContextResultCollection? in
return results?.results
}
|> `catch` { error -> Signal<ChatContextResultCollection?, NoError> in
return .single(nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private func channelVisibilityControllerEntries(presentationData: PresentationDa
}
} else if let _ = view.peers[view.peerId] as? TelegramGroup {
switch mode {
case .privateLink:
case .privateLink, .generic:
let link = (view.cachedData as? CachedGroupData)?.exportedInvitation?.link
let text: String
if let link = link {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ final class ThemeGridSearchContentNode: SearchDisplayControllerContentNode {
return (geoPoint.latitude, geoPoint.longitude)
}
return requestChatContextResults(account: self.context.account, botId: collection.botId, peerId: collection.peerId, query: searchContext.result.query, location: .single(geoPoint), offset: nextOffset)
|> map { results -> ChatContextResultCollection? in
return results?.results
}
|> `catch` { error -> Signal<ChatContextResultCollection?, NoError> in
return .single(nil)
}
Expand Down Expand Up @@ -535,6 +538,9 @@ final class ThemeGridSearchContentNode: SearchDisplayControllerContentNode {
return (.complete() |> delay(0.1, queue: Queue.concurrentDefaultQueue()))
|> then(
requestContextResults(account: context.account, botId: user.id, query: wallpaperQuery, peerId: context.account.peerId, limit: 16)
|> map { results -> ChatContextResultCollection? in
return results?.results
}
|> map { collection -> ([ThemeGridSearchEntry], Bool)? in
guard let collection = collection else {
return nil
Expand Down
Loading

0 comments on commit a5f9d41

Please sign in to comment.