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
laktyushin committed Jul 21, 2023
2 parents 709acb3 + 0564463 commit 2c6aa07
Show file tree
Hide file tree
Showing 47 changed files with 884 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ private final class NotificationServiceHandler {
}*/

if let storyId {
content.category = "st"
action = .pollStories(peerId: peerId, content: content, storyId: storyId)
} else {
action = .poll(peerId: peerId, content: content, messageId: messageIdValue)
Expand Down
25 changes: 19 additions & 6 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -9400,7 +9400,7 @@ Sorry for the inconvenience.";
"StoryFeed.ContextSavedStories" = "Saved Stories";
"StoryFeed.ContextArchivedStories" = "Archived Stories";
"StoryFeed.ContextOpenChat" = "Send Message";
"StoryFeed.ContextOpenProfile" = "View Profile";
"StoryFeed.ContextOpenProfile" = "Open Profile";
"StoryFeed.ContextNotifyOn" = "Notify About Stories";
"StoryFeed.ContextNotifyOff" = "Do Not Notify About Stories";
"StoryFeed.ContextArchive" = "Hide Stories";
Expand Down Expand Up @@ -9452,6 +9452,7 @@ Sorry for the inconvenience.";
"ArchiveSettings.UnknownChatsFooter" = "Automatically archive and mute new private chats, groups and channels from non-contacts.";

"ArchiveSettings.KeepArchived" = "Always Keep Archived";
"ArchiveSettings.AutomaticallyArchive" = "Automatically Archive";
"ArchiveSettings.TooltipPremiumRequired" = "This setting is available only to the subscribers of [Telegram Premium]().";

"NotificationSettings.Stories.ShowAll" = "Show All Notifications";
Expand Down Expand Up @@ -9548,10 +9549,9 @@ Sorry for the inconvenience.";

"Story.ContextDeleteStory" = "Delete Story";

"Story.TooltipPrivacyCloseFriends" = "You are seeing this story because you have\nbeen added to **%@'s** list of close friends.";
"Story.TooltipPrivacyCloseFriends" = "You are seeing this story because **%@** added you\nto their list of Close Friends.";
"Story.TooltipPrivacyContacts" = "Only **%@'s** contacts can view this story.";
"Story.TooltipPrivacySelectedContacts" = "Only some contacts **%@** selected can view this story.";

"Story.ToastViewInChat" = "View in Chat";
"Story.ToastReactionSent" = "Reaction Sent.";

Expand Down Expand Up @@ -9618,7 +9618,7 @@ Sorry for the inconvenience.";
"Story.Editor.DraftDiscardDraft" = "Discard Draft?";
"Story.Editor.DraftKeepMedia" = "Save Draft";
"Story.Editor.DraftKeepDraft" = "Keep Draft";
"Story.Editor.DraftDiscaedText" = "If you go back now, you will lose any changes that you've made.";
"Story.Editor.DraftDiscaedText" = "If you go back now, you will lose any changes you made.";
"Story.Editor.DraftDiscard" = "Discard";

"Story.Editor.ExpirationText" = "Choose how long the story will be visible.";
Expand Down Expand Up @@ -9679,7 +9679,7 @@ Sorry for the inconvenience.";
"Story.Privacy.TooltipStoryArchived" = "Users allowed to view your story will see it on your page even after it expires.";
"Story.Privacy.TooltipStoryExpires" = "The story will disappear after it expires.";

"Story.Privacy.WhoCanViewHeader" = "WHO CAN VIEW";
"Story.Privacy.WhoCanViewHeader" = "WHO CAN VIEW THIS STORY";
"Story.Privacy.ContactsHeader" = "CONTACTS";

"Story.Privacy.SearchChats" = "Search Chats";
Expand Down Expand Up @@ -9712,6 +9712,19 @@ Sorry for the inconvenience.";
"Story.Privacy.SaveSettings" = "Save Settings";
"Story.Privacy.PostStory" = "Post Story";

"Story.Editor.Draft" = "Draft";
"Story.Views.ViewsExpired" = "List of viewers becomes unavailable **24 hours** after the story expires.";
"Story.Views.NoViews" = "Nobody has viewed\nyour story yet.";

"AutoDownloadSettings.Stories" = "Stories";
"MediaEditor.Draft" = "Draft";

"Notification.LockScreenStoryPlaceholder" = "New Story";

"Chat.OpenStory" = "OPEN STORY";

"Story.Editor.TooltipPremiumCaptionLimitTitle" = "Maximum Length Reached";
"Story.Editor.TooltipPremiumCaptionLimitText" = "Increase this limit 10 times to 2048 symbols by subscribing to [Telegram Premium]().";

"Story.Editor.TooltipPremiumCaptionEntities" = "Subscribe to [Telegram Premium]() to add links and formatting in captions to your stories.";

"Story.Context.TooltipPremiumSaveStories" = "Subscribe to [Telegram Premium]() to save other people's unprotected stories to your Gallery.";
9 changes: 9 additions & 0 deletions submodules/AccountContext/Sources/UniversalVideoNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public protocol UniversalVideoContentNode: AnyObject {
func setSoundEnabled(_ value: Bool)
func seek(_ timestamp: Double)
func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek, actionAtEnd: MediaPlayerPlayOnceWithSoundActionAtEnd)
func setSoundMuted(soundMuted: Bool)
func continueWithOverridingAmbientMode(isAmbient: Bool)
func setForceAudioToSpeaker(_ forceAudioToSpeaker: Bool)
func continuePlayingWithoutSound(actionAtEnd: MediaPlayerPlayOnceWithSoundActionAtEnd)
Expand Down Expand Up @@ -284,6 +285,14 @@ public final class UniversalVideoNode: ASDisplayNode {
})
}

public func setSoundMuted(soundMuted: Bool) {
self.manager.withUniversalVideoContent(id: self.content.id, { contentNode in
if let contentNode = contentNode {
contentNode.setSoundMuted(soundMuted: soundMuted)
}
})
}

public func continueWithOverridingAmbientMode(isAmbient: Bool) {
self.manager.withUniversalVideoContent(id: self.content.id, { contentNode in
if let contentNode = contentNode {
Expand Down
180 changes: 92 additions & 88 deletions submodules/ChatListUI/Sources/ChatListController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1856,101 +1856,49 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
})

self.storySubscriptionsDisposable = (self.context.engine.messages.storySubscriptions(isHidden: self.location == .chatList(groupId: .archive))
|> deliverOnMainQueue).start(next: { [weak self] rawStorySubscriptions in
guard let self else {
return
}

self.rawStorySubscriptions = rawStorySubscriptions
var items: [EngineStorySubscriptions.Item] = []
if self.shouldFixStorySubscriptionOrder {
for peerId in self.fixedStorySubscriptionOrder {
if let item = rawStorySubscriptions.items.first(where: { $0.peer.id == peerId }) {
items.append(item)
}
}
}
for item in rawStorySubscriptions.items {
if !items.contains(where: { $0.peer.id == item.peer.id }) {
items.append(item)
}
}
self.orderedStorySubscriptions = EngineStorySubscriptions(
accountItem: rawStorySubscriptions.accountItem,
items: items,
hasMoreToken: rawStorySubscriptions.hasMoreToken
)
self.fixedStorySubscriptionOrder = items.map(\.peer.id)

let transition: ContainedViewLayoutTransition
if self.didAppear {
transition = .animated(duration: 0.4, curve: .spring)
} else {
transition = .immediate
}

self.chatListDisplayNode.temporaryContentOffsetChangeTransition = transition
self.requestLayout(transition: transition)
self.chatListDisplayNode.temporaryContentOffsetChangeTransition = nil

if !shouldDisplayStoriesInChatListHeader(storySubscriptions: rawStorySubscriptions, isHidden: self.location == .chatList(groupId: .archive)) {
self.chatListDisplayNode.scrollToTopIfStoriesAreExpanded()
}

if self.previewing {
self.storiesReady.set(.single(true))

Queue.mainQueue().after(1.0, { [weak self] in
guard let self else {
return
}
self.maybeDisplayStoryTooltip()
})
})
self.storyProgressDisposable = (self.context.engine.messages.allStoriesUploadProgress()
|> deliverOnMainQueue).start(next: { [weak self] progress in
guard let self else {
return
}
self.updateStoryUploadProgress(progress)
})

if case .chatList(.root) = self.location {
self.storyArchiveSubscriptionsDisposable = (self.context.engine.messages.storySubscriptions(isHidden: true)
|> deliverOnMainQueue).start(next: { [weak self] rawStoryArchiveSubscriptions in
} else {
self.storySubscriptionsDisposable = (self.context.engine.messages.storySubscriptions(isHidden: self.location == .chatList(groupId: .archive))
|> deliverOnMainQueue).start(next: { [weak self] rawStorySubscriptions in
guard let self else {
return
}

self.rawStoryArchiveSubscriptions = rawStoryArchiveSubscriptions

let archiveStoryState: ChatListNodeState.StoryState?
if rawStoryArchiveSubscriptions.items.isEmpty {
archiveStoryState = nil
} else {
var unseenCount = 0
for item in rawStoryArchiveSubscriptions.items {
if item.hasUnseen {
unseenCount += 1
self.rawStorySubscriptions = rawStorySubscriptions
var items: [EngineStorySubscriptions.Item] = []
if self.shouldFixStorySubscriptionOrder {
for peerId in self.fixedStorySubscriptionOrder {
if let item = rawStorySubscriptions.items.first(where: { $0.peer.id == peerId }) {
items.append(item)
}
}
let hasUnseenCloseFriends = rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseenCloseFriends })
archiveStoryState = ChatListNodeState.StoryState(
stats: EngineChatList.StoryStats(
totalCount: rawStoryArchiveSubscriptions.items.count,
unseenCount: unseenCount,
hasUnseenCloseFriends: hasUnseenCloseFriends
),
hasUnseenCloseFriends: hasUnseenCloseFriends
)
}
for item in rawStorySubscriptions.items {
if !items.contains(where: { $0.peer.id == item.peer.id }) {
items.append(item)
}
}
self.orderedStorySubscriptions = EngineStorySubscriptions(
accountItem: rawStorySubscriptions.accountItem,
items: items,
hasMoreToken: rawStorySubscriptions.hasMoreToken
)
self.fixedStorySubscriptionOrder = items.map(\.peer.id)

self.chatListDisplayNode.mainContainerNode.currentItemNode.updateState { chatListState in
var chatListState = chatListState

chatListState.archiveStoryState = archiveStoryState

return chatListState
let transition: ContainedViewLayoutTransition
if self.didAppear {
transition = .animated(duration: 0.4, curve: .spring)
} else {
transition = .immediate
}

self.chatListDisplayNode.temporaryContentOffsetChangeTransition = transition
self.requestLayout(transition: transition)
self.chatListDisplayNode.temporaryContentOffsetChangeTransition = nil

if !shouldDisplayStoriesInChatListHeader(storySubscriptions: rawStorySubscriptions, isHidden: self.location == .chatList(groupId: .archive)) {
self.chatListDisplayNode.scrollToTopIfStoriesAreExpanded()
}

self.storiesReady.set(.single(true))
Expand All @@ -1961,9 +1909,65 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
self.maybeDisplayStoryTooltip()
})

self.hasPendingStoriesPromise.set(rawStoryArchiveSubscriptions.accountItem?.hasPending ?? false)
})
self.storyProgressDisposable = (self.context.engine.messages.allStoriesUploadProgress()
|> deliverOnMainQueue).start(next: { [weak self] progress in
guard let self else {
return
}
self.updateStoryUploadProgress(progress)
})

if case .chatList(.root) = self.location {
self.storyArchiveSubscriptionsDisposable = (self.context.engine.messages.storySubscriptions(isHidden: true)
|> deliverOnMainQueue).start(next: { [weak self] rawStoryArchiveSubscriptions in
guard let self else {
return
}

self.rawStoryArchiveSubscriptions = rawStoryArchiveSubscriptions

let archiveStoryState: ChatListNodeState.StoryState?
if rawStoryArchiveSubscriptions.items.isEmpty {
archiveStoryState = nil
} else {
var unseenCount = 0
for item in rawStoryArchiveSubscriptions.items {
if item.hasUnseen {
unseenCount += 1
}
}
let hasUnseenCloseFriends = rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseenCloseFriends })
archiveStoryState = ChatListNodeState.StoryState(
stats: EngineChatList.StoryStats(
totalCount: rawStoryArchiveSubscriptions.items.count,
unseenCount: unseenCount,
hasUnseenCloseFriends: hasUnseenCloseFriends
),
hasUnseenCloseFriends: hasUnseenCloseFriends
)
}

self.chatListDisplayNode.mainContainerNode.currentItemNode.updateState { chatListState in
var chatListState = chatListState

chatListState.archiveStoryState = archiveStoryState

return chatListState
}

self.storiesReady.set(.single(true))

Queue.mainQueue().after(1.0, { [weak self] in
guard let self else {
return
}
self.maybeDisplayStoryTooltip()
})

self.hasPendingStoriesPromise.set(rawStoryArchiveSubscriptions.accountItem?.hasPending ?? false)
})
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/ChatListUI/Sources/ChatListControllerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
return
}

if let storySubscriptions = self.controller?.orderedStorySubscriptions {
if let controller = self.controller, let storySubscriptions = controller.orderedStorySubscriptions, shouldDisplayStoriesInChatListHeader(storySubscriptions: storySubscriptions, isHidden: controller.location == .chatList(groupId: .archive)) {
let _ = storySubscriptions

self.tempAllowAvatarExpansion = true
Expand Down
2 changes: 2 additions & 0 deletions submodules/ChatListUI/Sources/Node/ChatListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3601,6 +3601,8 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} else {
strongSelf.view.accessibilityCustomActions = nil
}

strongSelf.avatarTapRecognizer?.isEnabled = item.interaction.inlineNavigationLocation == nil
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/Display/Source/TextNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ open class TextNode: ASDisplayNode {
var additionalTrailingLine: (CTLine, Double)?

var measureFitWidth = CTLineGetTypographicBounds(originalLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(originalLine)
if customTruncationToken != nil {
if customTruncationToken != nil && lineRange.location + lineRange.length < attributedString.length {
measureFitWidth += truncationTokenWidth
}

Expand Down
Loading

0 comments on commit 2c6aa07

Please sign in to comment.