mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
743369eb0e
@ -849,7 +849,8 @@
|
|||||||
"MessageTimer.ShortWeeks_3_10" = "%@w";
|
"MessageTimer.ShortWeeks_3_10" = "%@w";
|
||||||
"MessageTimer.ShortWeeks_any" = "%@w";
|
"MessageTimer.ShortWeeks_any" = "%@w";
|
||||||
"MessageTimer.ShortWeeks_many" = "%@w";
|
"MessageTimer.ShortWeeks_many" = "%@w";
|
||||||
"MessageTimer.ShortWeeks_0" = "%@w";
|
"MessageTimer.ShortMonths_1" = "%@mo";
|
||||||
|
"MessageTimer.ShortMonths_any" = "%@mo";
|
||||||
|
|
||||||
"Activity.UploadingPhoto" = "sending photo";
|
"Activity.UploadingPhoto" = "sending photo";
|
||||||
"Activity.UploadingVideo" = "sending video";
|
"Activity.UploadingVideo" = "sending video";
|
||||||
|
@ -145,10 +145,12 @@ public struct ChatAvailableMessageActionOptions: OptionSet {
|
|||||||
public struct ChatAvailableMessageActions {
|
public struct ChatAvailableMessageActions {
|
||||||
public var options: ChatAvailableMessageActionOptions
|
public var options: ChatAvailableMessageActionOptions
|
||||||
public var banAuthor: Peer?
|
public var banAuthor: Peer?
|
||||||
|
public var disableDelete: Bool
|
||||||
|
|
||||||
public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?) {
|
public init(options: ChatAvailableMessageActionOptions, banAuthor: Peer?, disableDelete: Bool) {
|
||||||
self.options = options
|
self.options = options
|
||||||
self.banAuthor = banAuthor
|
self.banAuthor = banAuthor
|
||||||
|
self.disableDelete = disableDelete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,8 @@ public protocol Media: class, PostboxCoding {
|
|||||||
|
|
||||||
func isLikelyToBeUpdated() -> Bool
|
func isLikelyToBeUpdated() -> Bool
|
||||||
|
|
||||||
|
func preventsAutomaticMessageSendingFailure() -> Bool
|
||||||
|
|
||||||
func isEqual(to other: Media) -> Bool
|
func isEqual(to other: Media) -> Bool
|
||||||
func isSemanticallyEqual(to other: Media) -> Bool
|
func isSemanticallyEqual(to other: Media) -> Bool
|
||||||
}
|
}
|
||||||
@ -89,6 +91,10 @@ public extension Media {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func preventsAutomaticMessageSendingFailure() -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var indexableText: String? {
|
var indexableText: String? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1603,6 +1603,12 @@ public final class Postbox {
|
|||||||
for id in self.messageHistoryUnsentTable.get() {
|
for id in self.messageHistoryUnsentTable.get() {
|
||||||
transaction.updateMessage(id, update: { message in
|
transaction.updateMessage(id, update: { message in
|
||||||
if !message.flags.contains(.Failed) {
|
if !message.flags.contains(.Failed) {
|
||||||
|
for media in message.media {
|
||||||
|
if media.preventsAutomaticMessageSendingFailure() {
|
||||||
|
return .skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if message.timestamp + 60 * 10 > timestampForAbsoluteTimeBasedOperations {
|
if message.timestamp + 60 * 10 > timestampForAbsoluteTimeBasedOperations {
|
||||||
return .skip
|
return .skip
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,13 @@ public final class TelegramMediaAction: Media {
|
|||||||
|
|
||||||
public let action: TelegramMediaActionType
|
public let action: TelegramMediaActionType
|
||||||
|
|
||||||
|
public func preventsAutomaticMessageSendingFailure() -> Bool {
|
||||||
|
if case .historyScreenshot = self.action {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
public init(action: TelegramMediaActionType) {
|
public init(action: TelegramMediaActionType) {
|
||||||
self.action = action
|
self.action = action
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,10 @@ public func shortTimeIntervalString(strings: PresentationStrings, value: Int32)
|
|||||||
return strings.MessageTimer_ShortHours(max(1, value / (60 * 60)))
|
return strings.MessageTimer_ShortHours(max(1, value / (60 * 60)))
|
||||||
} else if value < 60 * 60 * 24 * 7 {
|
} else if value < 60 * 60 * 24 * 7 {
|
||||||
return strings.MessageTimer_ShortDays(max(1, value / (60 * 60 * 24)))
|
return strings.MessageTimer_ShortDays(max(1, value / (60 * 60 * 24)))
|
||||||
} else {
|
} else if value < 60 * 60 * 24 * 31 {
|
||||||
return strings.MessageTimer_ShortWeeks(max(1, value / (60 * 60 * 24 * 7)))
|
return strings.MessageTimer_ShortWeeks(max(1, value / (60 * 60 * 24 * 7)))
|
||||||
|
} else {
|
||||||
|
return strings.MessageTimer_ShortMonths(max(1, value / (60 * 60 * 24 * 7 * 30)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,6 +1059,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
|||||||
var banPeer: Peer?
|
var banPeer: Peer?
|
||||||
var hadPersonalIncoming = false
|
var hadPersonalIncoming = false
|
||||||
var hadBanPeerId = false
|
var hadBanPeerId = false
|
||||||
|
var disableDelete = false
|
||||||
|
|
||||||
func getPeer(_ peerId: PeerId) -> Peer? {
|
func getPeer(_ peerId: PeerId) -> Peer? {
|
||||||
if let peer = transaction.getPeer(peerId) {
|
if let peer = transaction.getPeer(peerId) {
|
||||||
@ -1229,6 +1230,15 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
|||||||
if canDeleteGlobally {
|
if canDeleteGlobally {
|
||||||
optionsMap[id]!.insert(.deleteGlobally)
|
optionsMap[id]!.insert(.deleteGlobally)
|
||||||
}
|
}
|
||||||
|
for media in message.media {
|
||||||
|
if let action = media as? TelegramMediaAction {
|
||||||
|
if case .historyScreenshot = action.action {
|
||||||
|
optionsMap[id]!.remove(.deleteLocally)
|
||||||
|
optionsMap[id]!.remove(.deleteGlobally)
|
||||||
|
disableDelete = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if user.botInfo != nil && message.flags.contains(.Incoming) && !user.id.isReplies && !isAction {
|
if user.botInfo != nil && message.flags.contains(.Incoming) && !user.id.isReplies && !isAction {
|
||||||
optionsMap[id]!.insert(.report)
|
optionsMap[id]!.insert(.report)
|
||||||
}
|
}
|
||||||
@ -1239,6 +1249,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
|||||||
switch action.action {
|
switch action.action {
|
||||||
case .historyScreenshot:
|
case .historyScreenshot:
|
||||||
isNonRemovableServiceAction = true
|
isNonRemovableServiceAction = true
|
||||||
|
disableDelete = true
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1265,9 +1276,9 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
|||||||
if hadPersonalIncoming && optionsMap.values.contains(where: { $0.contains(.deleteGlobally) }) && !reducedOptions.contains(.deleteGlobally) {
|
if hadPersonalIncoming && optionsMap.values.contains(where: { $0.contains(.deleteGlobally) }) && !reducedOptions.contains(.deleteGlobally) {
|
||||||
reducedOptions.insert(.unsendPersonal)
|
reducedOptions.insert(.unsendPersonal)
|
||||||
}
|
}
|
||||||
return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer)
|
return ChatAvailableMessageActions(options: reducedOptions, banAuthor: banPeer, disableDelete: disableDelete)
|
||||||
} else {
|
} else {
|
||||||
return ChatAvailableMessageActions(options: [], banAuthor: nil)
|
return ChatAvailableMessageActions(options: [], banAuthor: nil, disableDelete: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ final class ChatMessageSelectionInputPanelNode: ChatInputPanelNode {
|
|||||||
if self.peerMedia {
|
if self.peerMedia {
|
||||||
self.deleteButton.isEnabled = !actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty
|
self.deleteButton.isEnabled = !actions.options.intersection([.deleteLocally, .deleteGlobally]).isEmpty
|
||||||
} else {
|
} else {
|
||||||
self.deleteButton.isEnabled = true
|
self.deleteButton.isEnabled = !actions.disableDelete
|
||||||
}
|
}
|
||||||
self.shareButton.isEnabled = !actions.options.intersection([.forward]).isEmpty
|
self.shareButton.isEnabled = !actions.options.intersection([.forward]).isEmpty
|
||||||
self.reportButton.isEnabled = !actions.options.intersection([.report]).isEmpty
|
self.reportButton.isEnabled = !actions.options.intersection([.report]).isEmpty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user