Merge commit '4fa93eae2213e047cf0abf1dc48d795a1e612dd7'

This commit is contained in:
Ali 2021-05-04 22:29:07 +04:00
commit 56c32e930f
5 changed files with 32 additions and 14 deletions

View File

@ -382,19 +382,19 @@ public enum GetGroupCallParticipantsError {
} }
public func getGroupCallParticipants(account: Account, callId: Int64, accessHash: Int64, offset: String, ssrcs: [UInt32], limit: Int32, sortAscending: Bool?) -> Signal<GroupCallParticipantsContext.State, GetGroupCallParticipantsError> { public func getGroupCallParticipants(account: Account, callId: Int64, accessHash: Int64, offset: String, ssrcs: [UInt32], limit: Int32, sortAscending: Bool?) -> Signal<GroupCallParticipantsContext.State, GetGroupCallParticipantsError> {
let sortAscendingValue: Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?), GetGroupCallParticipantsError> let sortAscendingValue: Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool), GetGroupCallParticipantsError>
if let sortAscending = sortAscending { if let sortAscending = sortAscending {
sortAscendingValue = .single((sortAscending, nil, false, nil)) sortAscendingValue = .single((sortAscending, nil, false, nil, false))
} else { } else {
sortAscendingValue = getCurrentGroupCall(account: account, callId: callId, accessHash: accessHash) sortAscendingValue = getCurrentGroupCall(account: account, callId: callId, accessHash: accessHash)
|> mapError { _ -> GetGroupCallParticipantsError in |> mapError { _ -> GetGroupCallParticipantsError in
return .generic return .generic
} }
|> mapToSignal { result -> Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?), GetGroupCallParticipantsError> in |> mapToSignal { result -> Signal<(Bool, Int32?, Bool, GroupCallParticipantsContext.State.DefaultParticipantsAreMuted?, Bool), GetGroupCallParticipantsError> in
guard let result = result else { guard let result = result else {
return .fail(.generic) return .fail(.generic)
} }
return .single((result.info.sortAscending, result.info.scheduleTimestamp, result.info.subscribedToScheduled, result.info.defaultParticipantsAreMuted)) return .single((result.info.sortAscending, result.info.scheduleTimestamp, result.info.subscribedToScheduled, result.info.defaultParticipantsAreMuted, result.info.isVideoEnabled))
} }
} }
@ -412,7 +412,8 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
let version: Int32 let version: Int32
let nextParticipantsFetchOffset: String? let nextParticipantsFetchOffset: String?
let (sortAscendingValue, scheduleTimestamp, subscribedToScheduled, defaultParticipantsAreMuted) = sortAscendingAndScheduleTimestamp let (sortAscendingValue, scheduleTimestamp, subscribedToScheduled, defaultParticipantsAreMuted, isVideoEnabled) = sortAscendingAndScheduleTimestamp
switch result { switch result {
case let .groupParticipants(count, participants, nextOffset, chats, users, apiVersion): case let .groupParticipants(count, participants, nextOffset, chats, users, apiVersion):
@ -510,7 +511,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
scheduleTimestamp: scheduleTimestamp, scheduleTimestamp: scheduleTimestamp,
subscribedToScheduled: subscribedToScheduled, subscribedToScheduled: subscribedToScheduled,
totalCount: totalCount, totalCount: totalCount,
isVideoEnabled: false, isVideoEnabled: isVideoEnabled,
version: version version: version
) )
} }

View File

@ -59,14 +59,24 @@ public struct SearchStickersScope: OptionSet {
} }
func _internal_randomGreetingSticker(account: Account) -> Signal<FoundStickerItem?, NoError> { func _internal_randomGreetingSticker(account: Account) -> Signal<FoundStickerItem?, NoError> {
return account.postbox.transaction { transaction -> FoundStickerItem? in let key: PostboxViewKey = .orderedItemList(id: Namespaces.OrderedItemList.CloudGreetingStickers)
var stickerItems: [FoundStickerItem] = [] return account.postbox.combinedView(keys: [key])
for entry in transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudGreetingStickers) { |> map { views -> [OrderedItemListEntry]? in
if let item = entry.contents as? RecentMediaItem, let file = item.media as? TelegramMediaFile { if let view = views.views[key] as? OrderedItemListView, !view.items.isEmpty {
stickerItems.append(FoundStickerItem(file: file, stringRepresentations: [])) return view.items
} else {
return nil
} }
} }
return stickerItems.randomElement() |> filter { items in
return items != nil
}
|> take(1)
|> map { items -> FoundStickerItem? in
if let randomItem = items?.randomElement(), let item = randomItem.contents as? RecentMediaItem, let file = item.media as? TelegramMediaFile {
return FoundStickerItem(file: file, stringRepresentations: [])
}
return nil
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -853,6 +853,7 @@ final class ChatEmptyNode: ASDisplayNode {
contentType = .regular contentType = .regular
} }
var updateGreetingSticker = false
var contentTransition = transition var contentTransition = transition
if self.content?.0 != contentType { if self.content?.0 != contentType {
var animateContentIn = false var animateContentIn = false
@ -876,7 +877,7 @@ final class ChatEmptyNode: ASDisplayNode {
node = ChatEmptyNodeNearbyChatContent(context: self.context, interaction: self.interaction) node = ChatEmptyNodeNearbyChatContent(context: self.context, interaction: self.interaction)
case .greeting: case .greeting:
node = ChatEmptyNodeGreetingChatContent(context: self.context, interaction: self.interaction) node = ChatEmptyNodeGreetingChatContent(context: self.context, interaction: self.interaction)
self.context.prefetchManager?.prepareNextGreetingSticker() updateGreetingSticker = true
} }
self.content = (contentType, node) self.content = (contentType, node)
self.addSubnode(node) self.addSubnode(node)
@ -894,6 +895,10 @@ final class ChatEmptyNode: ASDisplayNode {
var contentSize = CGSize() var contentSize = CGSize()
if let contentNode = self.content?.1 { if let contentNode = self.content?.1 {
contentSize = contentNode.updateLayout(interfaceState: interfaceState, size: displayRect.size, transition: contentTransition) contentSize = contentNode.updateLayout(interfaceState: interfaceState, size: displayRect.size, transition: contentTransition)
if updateGreetingSticker {
self.context.prefetchManager?.prepareNextGreetingSticker()
}
} }
let contentFrame = CGRect(origin: CGPoint(x: displayRect.minX + floor((displayRect.width - contentSize.width) / 2.0), y: displayRect.minY + floor((displayRect.height - contentSize.height) / 2.0)), size: contentSize) let contentFrame = CGRect(origin: CGPoint(x: displayRect.minX + floor((displayRect.width - contentSize.width) / 2.0), y: displayRect.minY + floor((displayRect.height - contentSize.height) / 2.0)), size: contentSize)