mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
5749548ac8
commit
498ce24a09
@ -193,7 +193,7 @@ public final class MediaPlayerTimeTextNode: ASDisplayNode {
|
||||
self.state = MediaPlayerTimeTextNodeState(hours: timestamp / (60 * 60), minutes: timestamp % (60 * 60) / 60, seconds: timestamp % 60)
|
||||
} else {
|
||||
let timestampSeconds: Double
|
||||
if !statusValue.generationTimestamp.isZero {
|
||||
if !statusValue.generationTimestamp.isZero && isPlaying {
|
||||
timestampSeconds = timestamp + (CACurrentMediaTime() - statusValue.generationTimestamp)
|
||||
} else {
|
||||
timestampSeconds = timestamp
|
||||
|
@ -433,8 +433,7 @@ public final class ProfileSavedMusicContext {
|
||||
self.count = count + 1
|
||||
}
|
||||
}
|
||||
self.files = updatedFiles
|
||||
|
||||
self.files = updatedFiles
|
||||
self.pushState()
|
||||
|
||||
if apply {
|
||||
|
@ -6021,39 +6021,45 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
self.previousSavedMusicTimestamp = currentTimestamp
|
||||
|
||||
let peerId = self.peerId
|
||||
let initialId: Int32
|
||||
if let initialFileId = self.data?.savedMusicState?.files.first?.fileId {
|
||||
initialId = Int32(clamping: initialFileId.id % Int64(Int32.max))
|
||||
} else {
|
||||
initialId = 0
|
||||
}
|
||||
|
||||
let playlistLocation: PeerMessagesPlaylistLocation = .savedMusic(context: savedMusicContext, at: initialId, canReorder: peerId == self.context.account.peerId)
|
||||
let _ = (self.context.sharedContext.mediaManager.globalMediaPlayerState
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] accountStateAndType in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let peerId = self.peerId
|
||||
var initialId: Int32
|
||||
if let initialFileId = self.data?.savedMusicState?.files.first?.fileId {
|
||||
initialId = Int32(clamping: initialFileId.id % Int64(Int32.max))
|
||||
} else {
|
||||
initialId = 0
|
||||
}
|
||||
|
||||
let canReorder = peerId == self.context.account.peerId
|
||||
var playlistLocation: PeerMessagesPlaylistLocation = .savedMusic(context: savedMusicContext, at: initialId, canReorder: canReorder)
|
||||
|
||||
if let (account, stateOrLoading, _) = accountStateAndType, self.context.account.peerId == account.peerId, case let .state(state) = stateOrLoading, let location = state.playlistLocation as? PeerMessagesPlaylistLocation, case let .savedMusic(savedMusicContext, _, _) = location, savedMusicContext.peerId == peerId {
|
||||
if let itemId = state.item.id as? PeerMessagesMediaPlaylistItemId {
|
||||
initialId = itemId.messageId.id
|
||||
}
|
||||
playlistLocation = .savedMusic(context: savedMusicContext, at: initialId, canReorder: canReorder)
|
||||
} else {
|
||||
self.context.sharedContext.mediaManager.setPlaylist((self.context, PeerMessagesMediaPlaylist(context: self.context, location: playlistLocation, chatLocationContextHolder: nil)), type: .music, control: .playback(.play))
|
||||
}
|
||||
|
||||
Queue.mainQueue().after(0.1) {
|
||||
let musicController = self.context.sharedContext.makeOverlayAudioPlayerController(
|
||||
context: self.context,
|
||||
chatLocation: .peer(id: peerId),
|
||||
type: .music,
|
||||
initialMessageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: initialId),
|
||||
initialOrder: .regular,
|
||||
playlistLocation: playlistLocation,
|
||||
parentNavigationController: self.controller?.navigationController as? NavigationController
|
||||
)
|
||||
self.controller?.present(musicController, in: .window(.root))
|
||||
}
|
||||
})
|
||||
|
||||
Queue.mainQueue().after(0.1) {
|
||||
let musicController = self.context.sharedContext.makeOverlayAudioPlayerController(
|
||||
context: self.context,
|
||||
chatLocation: .peer(id: peerId),
|
||||
type: .music,
|
||||
initialMessageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: initialId),
|
||||
initialOrder: .regular,
|
||||
playlistLocation: playlistLocation,
|
||||
parentNavigationController: self.controller?.navigationController as? NavigationController
|
||||
)
|
||||
self.controller?.present(musicController, in: .window(.root))
|
||||
}
|
||||
}
|
||||
|
||||
private func performButtonAction(key: PeerInfoHeaderButtonKey, gesture: ContextGesture?) {
|
||||
|
@ -1286,11 +1286,24 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
||||
}
|
||||
if subscription.untilDate > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) {
|
||||
var updated = false
|
||||
if let channel = subscription.peer._asPeer() as? TelegramChannel, channel.participationStatus == .left && !subscription.flags.contains(.isCancelled) {
|
||||
|
||||
var hasLeft = false
|
||||
var isKicked = false
|
||||
if let channel = subscription.peer._asPeer() as? TelegramChannel {
|
||||
switch channel.participationStatus {
|
||||
case .left:
|
||||
hasLeft = true
|
||||
case .kicked:
|
||||
isKicked = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if hasLeft && !subscription.flags.contains(.isCancelled) {
|
||||
let _ = self.context.engine.payments.fulfillStarsSubscription(peerId: context.account.peerId, subscriptionId: subscription.id).startStandalone()
|
||||
updated = true
|
||||
}
|
||||
if let _ = subscription.inviteHash, !subscription.flags.contains(.isCancelledByBot) {
|
||||
} else if let _ = subscription.inviteHash, hasLeft && !isKicked && !subscription.flags.contains(.isCancelledByBot) {
|
||||
let _ = self.context.engine.payments.fulfillStarsSubscription(peerId: context.account.peerId, subscriptionId: subscription.id).startStandalone()
|
||||
updated = true
|
||||
}
|
||||
|
@ -1908,7 +1908,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
let disableAnimations = true
|
||||
let forceSynchronous = true
|
||||
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: false, chatLocation: chatLocation, controllerInteraction: controllerInteraction, scrollPosition: nil, scrollAnimationCurve: nil, initialData: initialData?.initialData, keyboardButtonsMessage: nil, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: false, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: false)
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: false, chatLocation: chatLocation, source: source, controllerInteraction: controllerInteraction, scrollPosition: nil, scrollAnimationCurve: nil, initialData: initialData?.initialData, keyboardButtonsMessage: nil, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: false, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: false)
|
||||
var mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: previousViewValue.associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: 0, isSavedMusic: isSavedMusic, canReorder: canReorder, animateFromPreviousFilter: resetScrolling, transition: rawTransition)
|
||||
|
||||
if disableAnimations {
|
||||
@ -2299,7 +2299,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
keyboardButtonsMessage = nil
|
||||
}
|
||||
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: reverse, chatLocation: chatLocation, controllerInteraction: controllerInteraction, scrollPosition: updatedScrollPosition, scrollAnimationCurve: scrollAnimationCurve, initialData: initialData?.initialData, keyboardButtonsMessage: keyboardButtonsMessage, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: flashIndicators, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: !isSavedMusic || forceUpdateAll)
|
||||
let rawTransition = preparedChatHistoryViewTransition(from: previous, to: processedView, reason: reason, reverse: reverse, chatLocation: chatLocation, source: source, controllerInteraction: controllerInteraction, scrollPosition: updatedScrollPosition, scrollAnimationCurve: scrollAnimationCurve, initialData: initialData?.initialData, keyboardButtonsMessage: keyboardButtonsMessage, cachedData: initialData?.cachedData, cachedDataMessages: initialData?.cachedDataMessages, readStateData: initialData?.readStateData, flashIndicators: flashIndicators, updatedMessageSelection: previousSelectedMessages != selectedMessages, messageTransitionNode: messageTransitionNode(), allUpdated: !isSavedMusic || forceUpdateAll)
|
||||
var mappedTransition = mappedChatHistoryViewListTransition(context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, mode: mode, lastHeaderId: lastHeaderId, isSavedMusic: isSavedMusic, canReorder: canReorder, animateFromPreviousFilter: resetScrolling, transition: rawTransition)
|
||||
|
||||
if disableAnimations {
|
||||
|
@ -1097,9 +1097,13 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu
|
||||
})))
|
||||
}
|
||||
|
||||
items.append(.separator)
|
||||
var addedSeparator = false
|
||||
|
||||
if message.id.namespace == Namespaces.Message.Cloud {
|
||||
if !addedSeparator {
|
||||
items.append(.separator)
|
||||
addedSeparator = true
|
||||
}
|
||||
items.append(
|
||||
.action(ContextMenuActionItem(text: "Show in Chat", icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in
|
||||
f(.dismissWithoutContent)
|
||||
@ -1147,6 +1151,10 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu
|
||||
}
|
||||
|
||||
if canDelete {
|
||||
if !addedSeparator {
|
||||
items.append(.separator)
|
||||
addedSeparator = true
|
||||
}
|
||||
var actionTitle = "Delete"
|
||||
if case .custom = self.source {
|
||||
actionTitle = "Remove"
|
||||
|
@ -9,7 +9,7 @@ import ChatControllerInteraction
|
||||
import ChatHistoryEntry
|
||||
import ChatMessageBubbleItemNode
|
||||
|
||||
func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toView: ChatHistoryView, reason: ChatHistoryViewTransitionReason, reverse: Bool, chatLocation: ChatLocation, controllerInteraction: ChatControllerInteraction, scrollPosition: ChatHistoryViewScrollPosition?, scrollAnimationCurve: ListViewAnimationCurve?, initialData: InitialMessageHistoryData?, keyboardButtonsMessage: Message?, cachedData: CachedPeerData?, cachedDataMessages: [MessageId: Message]?, readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]?, flashIndicators: Bool, updatedMessageSelection: Bool, messageTransitionNode: ChatMessageTransitionNodeImpl?, allUpdated: Bool) -> ChatHistoryViewTransition {
|
||||
func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toView: ChatHistoryView, reason: ChatHistoryViewTransitionReason, reverse: Bool, chatLocation: ChatLocation, source: ChatHistoryListSource, controllerInteraction: ChatControllerInteraction, scrollPosition: ChatHistoryViewScrollPosition?, scrollAnimationCurve: ListViewAnimationCurve?, initialData: InitialMessageHistoryData?, keyboardButtonsMessage: Message?, cachedData: CachedPeerData?, cachedDataMessages: [MessageId: Message]?, readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]?, flashIndicators: Bool, updatedMessageSelection: Bool, messageTransitionNode: ChatMessageTransitionNodeImpl?, allUpdated: Bool) -> ChatHistoryViewTransition {
|
||||
var mergeResult: (deleteIndices: [Int], indicesAndItems: [(Int, ChatHistoryEntry, Int?)], updateIndices: [(Int, ChatHistoryEntry, Int)])
|
||||
let allUpdated = allUpdated || (fromView?.associatedData != toView.associatedData)
|
||||
if reverse {
|
||||
@ -141,6 +141,11 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
|
||||
|
||||
let curve: ListViewAnimationCurve = scrollAnimationCurve ?? .Default(duration: nil)
|
||||
|
||||
var isSavedMusic = false
|
||||
if case let .custom(_, _, _, isSavedMusicValue, _, _) = source {
|
||||
isSavedMusic = isSavedMusicValue
|
||||
}
|
||||
|
||||
if let scrollPosition = scrollPosition {
|
||||
switch scrollPosition {
|
||||
case let .unread(unreadIndex):
|
||||
@ -238,9 +243,17 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
|
||||
}
|
||||
var index = toView.filteredEntries.count - 1
|
||||
for entry in toView.filteredEntries {
|
||||
if scrollIndex.index.isLessOrEqual(to: entry.index) {
|
||||
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
|
||||
break
|
||||
if isSavedMusic {
|
||||
if case let .message(messageIndex) = scrollIndex.index, messageIndex.id == entry.index.id {
|
||||
print(messageIndex.id)
|
||||
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if scrollIndex.index.isLessOrEqual(to: entry.index) {
|
||||
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
|
||||
break
|
||||
}
|
||||
}
|
||||
index -= 1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user