Merge commit '8c033a37bc0dd0399a9607e44aecfba1e6725f10'

This commit is contained in:
Ali 2021-11-04 21:13:20 +04:00
commit 941d5d50c8
10 changed files with 79 additions and 19 deletions

View File

@ -6891,6 +6891,7 @@ Sorry for the inconvenience.";
"MemberRequests.DescriptionGroup" = "Some [additional links]() are set up to accept requests to join the group.";
"MemberRequests.DescriptionChannel" = "Some [additional links]() are set up to accept requests to join the channel.";
"MemberRequests.SearchPlaceholder" = "Search Join Requests";
"MemberRequests.PeopleRequested_1" = "%@ requested to join";
"MemberRequests.PeopleRequested_2" = "%@ requested to join";
"MemberRequests.PeopleRequested_3_10" = "%@ requested to join";
@ -6930,7 +6931,7 @@ Sorry for the inconvenience.";
"MemberRequests.RequestToJoinSentDescriptionGroup" = "You will be added to the group once it admins approve your request.";
"MemberRequests.RequestToJoinSentDescriptionChannel" = "You will be added to the channel once it admins approve your request.";
"Notification.JoinedChatByRequestYou" = "Your request to join the channel was approved";
"Notification.JoinedChannelByRequestYou" = "Your request to join the channel was approved";
"Notification.JoinedGroupByRequestYou" = "Your request to join the group was approved";
"Notification.JoinedGroupByRequest" = "%@ was accepted to the group chat";
@ -6992,6 +6993,8 @@ Sorry for the inconvenience.";
"Notifications.DeleteAllExceptions" = "Delete All Exceptions";
"Notifications.Options" = "Options";
"Notifications.On" = "On";
"Notifications.Off" = "Off";

View File

@ -72,7 +72,7 @@ final class SearchNavigationContentNode: NavigationBarContentNode, ItemListContr
}
func updatePlaceholder() {
self.searchBar.placeholderString = NSAttributedString(string: self.strings.Conversation_SearchByName_Placeholder, font: searchBarFont, textColor: self.theme.rootController.navigationSearchBar.inputPlaceholderTextColor)
self.searchBar.placeholderString = NSAttributedString(string: self.strings.MemberRequests_SearchPlaceholder, font: searchBarFont, textColor: self.theme.rootController.navigationSearchBar.inputPlaceholderTextColor)
}
override var nominalHeight: CGFloat {

View File

@ -68,6 +68,7 @@
- (SSignal *)captionSignalForItem:(NSObject<TGMediaEditableItem> *)item;
- (void)setCaption:(NSString *)caption entities:(NSArray *)entities forItem:(NSObject<TGMediaEditableItem> *)item;
- (bool)isForcedCaption;
- (void)setForcedCaption:(NSString *)caption entities:(NSArray *)entities;
- (NSObject<TGMediaEditAdjustments> *)adjustmentsForItem:(NSObject<TGMediaEditableItem> *)item;

View File

@ -908,6 +908,7 @@
NSNumber *groupedId;
NSInteger i = 0;
NSInteger num = 0;
bool grouping = selectionContext.grouping;
bool hasAnyTimers = false;
@ -938,15 +939,20 @@
asset = ((TGCameraCapturedVideo *)asset).originalAsset;
}
NSString *caption = [editingContext captionForItem:asset];
NSArray *entities = [editingContext entitiesForItem:asset];
if (editingContext.isForcedCaption && num > 0) {
caption = nil;
entities = nil;
}
switch (asset.type)
{
case TGMediaAssetPhotoType:
{
if (intent == TGMediaAssetsControllerSendFileIntent)
{
NSString *caption = [editingContext captionForItem:asset];
NSArray *entities = [editingContext entitiesForItem:asset];
[signals addObject:[[[TGMediaAssetImageSignals imageDataForAsset:asset allowNetworkAccess:false convertToJpeg:convertToJpeg] map:^NSDictionary *(TGMediaAssetImageData *assetData)
{
NSString *tempFileName = TGTemporaryFileName(nil);
@ -993,11 +999,10 @@
}]];
i++;
num++;
}
else
{
NSString *caption = [editingContext captionForItem:asset];
NSArray *entities = [editingContext entitiesForItem:asset];
id<TGMediaEditAdjustments> adjustments = [editingContext adjustmentsForItem:asset];
NSNumber *timer = [editingContext timerForItem:asset];
@ -1096,6 +1101,7 @@
}]];
i++;
num++;
}
else
{
@ -1181,6 +1187,7 @@
}
i++;
num++;
}
}
break;
@ -1189,8 +1196,6 @@
{
if (intent == TGMediaAssetsControllerSendFileIntent)
{
NSString *caption = [editingContext captionForItem:asset];
NSArray *entities = [editingContext entitiesForItem:asset];
id<TGMediaEditAdjustments> adjustments = [editingContext adjustmentsForItem:asset];
CGSize dimensions = asset.originalSize;
@ -1218,12 +1223,11 @@
}]];
i++;
num++;
}
else
{
TGVideoEditAdjustments *adjustments = (TGVideoEditAdjustments *)[editingContext adjustmentsForItem:asset];
NSString *caption = [editingContext captionForItem:asset];
NSArray *entities = [editingContext entitiesForItem:asset];
NSNumber *timer = [editingContext timerForItem:asset];
UIImage *(^cropVideoThumbnail)(UIImage *, CGSize, CGSize, bool) = ^UIImage *(UIImage *image, CGSize targetSize, CGSize sourceSize, bool resize)
@ -1288,6 +1292,7 @@
}]];
i++;
num++;
}
}
break;
@ -1300,8 +1305,6 @@
}
TGVideoEditAdjustments *adjustments = (TGVideoEditAdjustments *)[editingContext adjustmentsForItem:video];
NSString *caption = [editingContext captionForItem:video];
NSArray *entities = [editingContext entitiesForItem:video];
NSNumber *timer = [editingContext timerForItem:video];
UIImage *(^cropVideoThumbnail)(UIImage *, CGSize, CGSize, bool) = ^UIImage *(UIImage *image, CGSize targetSize, CGSize sourceSize, bool resize)
@ -1366,6 +1369,7 @@
}]];
i++;
num++;
}
break;

View File

@ -424,6 +424,10 @@
_captionPipe.sink([TGMediaCaptionUpdate captionUpdateWithItem:item caption:caption entities:entities]);
}
- (bool)isForcedCaption {
return _forcedCaption.length > 0;
}
- (void)setForcedCaption:(NSString *)caption entities:(NSArray *)entities
{
_forcedCaption = caption;

View File

@ -266,7 +266,7 @@ private func notificationsPeerCategoryEntries(category: NotificationsPeerCategor
entries.append(.enable(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, notificationSettings.enabled))
if notificationSettings.enabled || !notificationExceptions.isEmpty {
entries.append(.optionsHeader(presentationData.theme, presentationData.strings.Notifications_MessageNotifications.uppercased()))
entries.append(.optionsHeader(presentationData.theme, presentationData.strings.Notifications_Options.uppercased()))
entries.append(.previews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, notificationSettings.displayPreviews))
entries.append(.sound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(notificationSettings.sound)), filteredGlobalSound(notificationSettings.sound)))
}

View File

@ -490,9 +490,11 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
switch participantResult {
case let .channelParticipant(participant, _, _):
switch participant {
case let .channelParticipantSelf(_, _, inviterId, invitedDate):
case let .channelParticipantSelf(flags, _, inviterId, invitedDate):
invitedBy = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId))
invitedOn = invitedDate
if (flags & (1 << 0)) != 0 {
invitedOn = invitedDate
}
default:
break
}

View File

@ -262,7 +262,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_JoinedGroupByLink(authorName)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)]))
}
case .joinedByRequest:
if message.author?.id == accountPeerId {
if message.author?.id.namespace == Namespaces.Peer.CloudChannel {
attributedString = NSAttributedString(string: strings.Notification_JoinedChannelByRequestYou, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_JoinedGroupByRequestYou, font: titleFont, textColor: primaryTextColor)
} else if let peerId = message.author?.id {
attributedString = addAttributesToStringWithRanges(strings.Notification_JoinedGroupByRequest(authorName)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, peerId)]))

View File

@ -24,6 +24,7 @@ func chatHistoryEntriesForView(
updatingMedia: [MessageId: ChatUpdatingMessageMedia],
customChannelDiscussionReadState: MessageId?,
customThreadOutgoingReadState: MessageId?,
cachedData: CachedPeerData?,
adMessages: [Message]
) -> [ChatHistoryEntry] {
if historyAppearsCleared {
@ -32,6 +33,7 @@ func chatHistoryEntriesForView(
var entries: [ChatHistoryEntry] = []
var adminRanks: [PeerId: CachedChannelAdminRank] = [:]
var stickersEnabled = true
var channelPeer: Peer?
if case let .peer(peerId) = location, peerId.namespace == Namespaces.Peer.CloudChannel {
for additionalEntry in view.additionalData {
if case let .cacheEntry(id, data) = additionalEntry {
@ -39,14 +41,43 @@ func chatHistoryEntriesForView(
adminRanks = data.ranks
}
} else if case let .peer(_, peer) = additionalEntry, let channel = peer as? TelegramChannel, !channel.flags.contains(.isGigagroup) {
channelPeer = channel
if let defaultBannedRights = channel.defaultBannedRights, defaultBannedRights.flags.contains(.banSendStickers) {
stickersEnabled = false
}
}
}
}
var joinMessage: Message?
if case let .peer(peerId) = location, case let cachedData = cachedData as? CachedChannelData, let invitedOn = cachedData?.invitedOn {
joinMessage = Message(
stableId: UInt32.max - 1000,
stableVersion: 0,
id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: 0),
globallyUniqueId: nil,
groupingKey: nil,
groupInfo: nil,
threadId: nil,
timestamp: invitedOn,
flags: [.Incoming],
tags: [],
globalTags: [],
localTags: [],
forwardInfo: nil,
author: channelPeer,
text: "",
attributes: [],
media: [TelegramMediaAction(action: .joinedByRequest)],
peers: SimpleDictionary<PeerId, Peer>(),
associatedMessages: SimpleDictionary<MessageId, Message>(),
associatedMessageIds: []
)
}
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes)] = []
var count = 0
loop: for entry in view.entries {
var message = entry.message
var isRead = entry.isRead
@ -55,6 +86,14 @@ func chatHistoryEntriesForView(
continue
}
if let maybeJoinMessage = joinMessage {
if message.timestamp > maybeJoinMessage.timestamp, (!view.holeEarlier || count > 0) {
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false)))
joinMessage = nil
}
}
count += 1
if let customThreadOutgoingReadState = customThreadOutgoingReadState {
isRead = customThreadOutgoingReadState >= message.id
}
@ -95,7 +134,6 @@ func chatHistoryEntriesForView(
adminRank = adminRanks[author.id]
}
if presentationData.largeEmoji, message.media.isEmpty {
if stickersEnabled && message.text.count == 1, let _ = associatedData.animatedEmojiStickers[message.text.basicEmoji.0] {
contentTypeHint = .animatedEmoji
@ -142,6 +180,11 @@ func chatHistoryEntriesForView(
entries.append(.MessageGroupEntry(groupBucket[0].0.groupInfo!, groupBucket, presentationData))
}
if let maybeJoinMessage = joinMessage, !view.holeLater {
entries.append(.MessageEntry(maybeJoinMessage, presentationData, false, nil, .none, ChatMessageEntryAttributes(rank: nil, isContact: false, contentTypeHint: .generic, updatingMedia: nil, isPlaying: false)))
joinMessage = nil
}
if let maxReadIndex = view.maxReadIndex, includeUnreadEntry {
var i = 0
let unreadEntry: ChatHistoryEntry = .UnreadEntry(maxReadIndex, presentationData)

View File

@ -1070,6 +1070,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
updatingMedia: updatingMedia,
customChannelDiscussionReadState: customChannelDiscussionReadState,
customThreadOutgoingReadState: customThreadOutgoingReadState,
cachedData: data.cachedData,
adMessages: adMessages
)
let lastHeaderId = filteredEntries.last.flatMap { listMessageDateHeaderId(timestamp: $0.index.timestamp) } ?? 0