mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Unarchive
This commit is contained in:
parent
5c61225230
commit
84babc02b0
@ -5635,3 +5635,6 @@ Any member of this group will be able to see messages in the channel.";
|
||||
|
||||
"Settings.SetProfilePhotoOrVideo" = "Set Profile Photo or Video";
|
||||
"Settings.SetNewProfilePhotoOrVideo" = "Set New Profile Photo or Video";
|
||||
|
||||
"Conversation.Unarchive" = "Unarhive";
|
||||
"Conversation.UnarchiveDone" = "The chat was moved to your main list.";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
import SwiftSignalKit
|
||||
import SyncCore
|
||||
|
||||
extension PeerStatusSettings {
|
||||
@ -34,3 +34,22 @@ extension PeerStatusSettings {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func unarchiveAutomaticallyArchivedPeer(account: Account, peerId: PeerId) {
|
||||
let _ = (account.postbox.transaction { transaction -> Void in
|
||||
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
|
||||
guard let currentData = current as? CachedUserData, let currentStatusSettings = currentData.peerStatusSettings else {
|
||||
return current
|
||||
}
|
||||
var statusSettings = currentStatusSettings
|
||||
statusSettings.flags.remove(.canBlock)
|
||||
statusSettings.flags.remove(.canReport)
|
||||
statusSettings.flags.remove(.autoArchived)
|
||||
return currentData.withUpdatedPeerStatusSettings(statusSettings)
|
||||
})
|
||||
}
|
||||
|> deliverOnMainQueue).start()
|
||||
|
||||
let _ = updatePeerMuteSetting(account: account, peerId: peerId, muteInterval: nil).start()
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -4617,6 +4617,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return nil
|
||||
}))
|
||||
}
|
||||
}, unarchivePeer: { [weak self] in
|
||||
guard let strongSelf = self, case let .peer(peerId) = strongSelf.chatLocation else {
|
||||
return
|
||||
}
|
||||
unarchiveAutomaticallyArchivedPeer(account: strongSelf.context.account, peerId: peerId)
|
||||
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .succeed(text: strongSelf.presentationData.strings.Conversation_UnarchiveDone), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
}, statuses: ChatPanelInterfaceInteractionStatuses(editingMessage: self.editingMessage.get(), startingBot: self.startingBot.get(), unblockingPeer: self.unblockingPeer.get(), searching: self.searching.get(), loadingMessage: self.loadingMessage.get(), inlineSearch: self.performingInlineSearch.get()))
|
||||
|
||||
switch self.chatLocation {
|
||||
|
@ -35,7 +35,7 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
|
||||
if !peerStatusSettings.flags.isEmpty {
|
||||
if contactStatus.canAddContact && peerStatusSettings.contains(.canAddContact) {
|
||||
displayActionsPanel = true
|
||||
} else if peerStatusSettings.contains(.canReport) || peerStatusSettings.contains(.canBlock) {
|
||||
} else if peerStatusSettings.contains(.canReport) || peerStatusSettings.contains(.canBlock) || peerStatusSettings.contains(.autoArchived) {
|
||||
displayActionsPanel = true
|
||||
} else if peerStatusSettings.contains(.canShareContact) {
|
||||
displayActionsPanel = true
|
||||
|
@ -119,9 +119,82 @@ final class ChatPanelInterfaceInteraction {
|
||||
let openScheduledMessages: () -> Void
|
||||
let displaySearchResultsTooltip: (ASDisplayNode, CGRect) -> Void
|
||||
let openPeersNearby: () -> Void
|
||||
let unarchivePeer: () -> Void
|
||||
let statuses: ChatPanelInterfaceInteractionStatuses?
|
||||
|
||||
init(setupReplyMessage: @escaping (MessageId, @escaping (ContainedViewLayoutTransition) -> Void) -> Void, setupEditMessage: @escaping (MessageId?, @escaping (ContainedViewLayoutTransition) -> Void) -> Void, beginMessageSelection: @escaping ([MessageId], @escaping (ContainedViewLayoutTransition) -> Void) -> Void, deleteSelectedMessages: @escaping () -> Void, reportSelectedMessages: @escaping () -> Void, reportMessages: @escaping ([Message], ContextController?) -> Void, deleteMessages: @escaping ([Message], ContextController?, @escaping (ContextMenuActionResult) -> Void) -> Void, forwardSelectedMessages: @escaping () -> Void, forwardCurrentForwardMessages: @escaping () -> Void, forwardMessages: @escaping ([Message]) -> Void, shareSelectedMessages: @escaping () -> Void, updateTextInputStateAndMode: @escaping ((ChatTextInputState, ChatInputMode) -> (ChatTextInputState, ChatInputMode)) -> Void, updateInputModeAndDismissedButtonKeyboardMessageId: @escaping ((ChatPresentationInterfaceState) -> (ChatInputMode, MessageId?)) -> Void, openStickers: @escaping () -> Void, editMessage: @escaping () -> Void, beginMessageSearch: @escaping (ChatSearchDomain, String) -> Void, dismissMessageSearch: @escaping () -> Void, updateMessageSearch: @escaping (String) -> Void, openSearchResults: @escaping () -> Void, navigateMessageSearch: @escaping (ChatPanelSearchNavigationAction) -> Void, openCalendarSearch: @escaping () -> Void, toggleMembersSearch: @escaping (Bool) -> Void, navigateToMessage: @escaping (MessageId) -> Void, navigateToChat: @escaping (PeerId) -> Void, navigateToProfile: @escaping (PeerId) -> Void, openPeerInfo: @escaping () -> Void, togglePeerNotifications: @escaping () -> Void, sendContextResult: @escaping (ChatContextResultCollection, ChatContextResult, ASDisplayNode, CGRect) -> Bool, sendBotCommand: @escaping (Peer, String) -> Void, sendBotStart: @escaping (String?) -> Void, botSwitchChatWithPayload: @escaping (PeerId, String) -> Void, beginMediaRecording: @escaping (Bool) -> Void, finishMediaRecording: @escaping (ChatFinishMediaRecordingAction) -> Void, stopMediaRecording: @escaping () -> Void, lockMediaRecording: @escaping () -> Void, deleteRecordedMedia: @escaping () -> Void, sendRecordedMedia: @escaping () -> Void, displayRestrictedInfo: @escaping (ChatPanelRestrictionInfoSubject, ChatPanelRestrictionInfoDisplayType) -> Void, displayVideoUnmuteTip: @escaping (CGPoint?) -> Void, switchMediaRecordingMode: @escaping () -> Void, setupMessageAutoremoveTimeout: @escaping () -> Void, sendSticker: @escaping (FileMediaReference, ASDisplayNode, CGRect) -> Bool, unblockPeer: @escaping () -> Void, pinMessage: @escaping (MessageId) -> Void, unpinMessage: @escaping () -> Void, shareAccountContact: @escaping () -> Void, reportPeer: @escaping () -> Void, presentPeerContact: @escaping () -> Void, dismissReportPeer: @escaping () -> Void, deleteChat: @escaping () -> Void, beginCall: @escaping (Bool) -> Void, toggleMessageStickerStarred: @escaping (MessageId) -> Void, presentController: @escaping (ViewController, Any?) -> Void, getNavigationController: @escaping () -> NavigationController?, presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void, navigateFeed: @escaping () -> Void, openGrouping: @escaping () -> Void, toggleSilentPost: @escaping () -> Void, requestUnvoteInMessage: @escaping (MessageId) -> Void, requestStopPollInMessage: @escaping (MessageId) -> Void, updateInputLanguage: @escaping ((String?) -> String?) -> Void, unarchiveChat: @escaping () -> Void, openLinkEditing: @escaping () -> Void, reportPeerIrrelevantGeoLocation: @escaping () -> Void, displaySlowmodeTooltip: @escaping (ASDisplayNode, CGRect) -> Void, displaySendMessageOptions: @escaping (ASDisplayNode, ContextGesture) -> Void, openScheduledMessages: @escaping () -> Void, openPeersNearby: @escaping () -> Void, displaySearchResultsTooltip: @escaping (ASDisplayNode, CGRect) -> Void, statuses: ChatPanelInterfaceInteractionStatuses?) {
|
||||
init(
|
||||
setupReplyMessage: @escaping (MessageId, @escaping (ContainedViewLayoutTransition) -> Void) -> Void,
|
||||
setupEditMessage: @escaping (MessageId?, @escaping (ContainedViewLayoutTransition) -> Void) -> Void,
|
||||
beginMessageSelection: @escaping ([MessageId], @escaping (ContainedViewLayoutTransition) -> Void) -> Void,
|
||||
deleteSelectedMessages: @escaping () -> Void,
|
||||
reportSelectedMessages: @escaping () -> Void,
|
||||
reportMessages: @escaping ([Message], ContextController?) -> Void,
|
||||
deleteMessages: @escaping ([Message], ContextController?, @escaping (ContextMenuActionResult) -> Void) -> Void,
|
||||
forwardSelectedMessages: @escaping () -> Void,
|
||||
forwardCurrentForwardMessages: @escaping () -> Void,
|
||||
forwardMessages: @escaping ([Message]) -> Void,
|
||||
shareSelectedMessages: @escaping () -> Void,
|
||||
updateTextInputStateAndMode: @escaping ((ChatTextInputState, ChatInputMode) -> (ChatTextInputState, ChatInputMode)) -> Void,
|
||||
updateInputModeAndDismissedButtonKeyboardMessageId: @escaping ((ChatPresentationInterfaceState) -> (ChatInputMode, MessageId?)) -> Void,
|
||||
openStickers: @escaping () -> Void,
|
||||
editMessage: @escaping () -> Void,
|
||||
beginMessageSearch: @escaping (ChatSearchDomain, String) -> Void,
|
||||
dismissMessageSearch: @escaping () -> Void,
|
||||
updateMessageSearch: @escaping (String) -> Void,
|
||||
openSearchResults: @escaping () -> Void,
|
||||
navigateMessageSearch: @escaping (ChatPanelSearchNavigationAction) -> Void,
|
||||
openCalendarSearch: @escaping () -> Void,
|
||||
toggleMembersSearch: @escaping (Bool) -> Void,
|
||||
navigateToMessage: @escaping (MessageId) -> Void,
|
||||
navigateToChat: @escaping (PeerId) -> Void,
|
||||
navigateToProfile: @escaping (PeerId) -> Void,
|
||||
openPeerInfo: @escaping () -> Void,
|
||||
togglePeerNotifications: @escaping () -> Void,
|
||||
sendContextResult: @escaping (ChatContextResultCollection, ChatContextResult, ASDisplayNode, CGRect) -> Bool,
|
||||
sendBotCommand: @escaping (Peer, String) -> Void,
|
||||
sendBotStart: @escaping (String?) -> Void,
|
||||
botSwitchChatWithPayload: @escaping (PeerId, String) -> Void,
|
||||
beginMediaRecording: @escaping (Bool) -> Void,
|
||||
finishMediaRecording: @escaping (ChatFinishMediaRecordingAction) -> Void,
|
||||
stopMediaRecording: @escaping () -> Void,
|
||||
lockMediaRecording: @escaping () -> Void,
|
||||
deleteRecordedMedia: @escaping () -> Void,
|
||||
sendRecordedMedia: @escaping () -> Void,
|
||||
displayRestrictedInfo: @escaping (ChatPanelRestrictionInfoSubject, ChatPanelRestrictionInfoDisplayType) -> Void,
|
||||
displayVideoUnmuteTip: @escaping (CGPoint?) -> Void,
|
||||
switchMediaRecordingMode: @escaping () -> Void,
|
||||
setupMessageAutoremoveTimeout: @escaping () -> Void,
|
||||
sendSticker: @escaping (FileMediaReference, ASDisplayNode, CGRect) -> Bool,
|
||||
unblockPeer: @escaping () -> Void,
|
||||
pinMessage: @escaping (MessageId) -> Void,
|
||||
unpinMessage: @escaping () -> Void,
|
||||
shareAccountContact: @escaping () -> Void,
|
||||
reportPeer: @escaping () -> Void,
|
||||
presentPeerContact: @escaping () -> Void,
|
||||
dismissReportPeer: @escaping () -> Void,
|
||||
deleteChat: @escaping () -> Void,
|
||||
beginCall: @escaping (Bool) -> Void,
|
||||
toggleMessageStickerStarred: @escaping (MessageId) -> Void,
|
||||
presentController: @escaping (ViewController, Any?) -> Void,
|
||||
getNavigationController: @escaping () -> NavigationController?,
|
||||
presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void,
|
||||
navigateFeed: @escaping () -> Void,
|
||||
openGrouping: @escaping () -> Void,
|
||||
toggleSilentPost: @escaping () -> Void,
|
||||
requestUnvoteInMessage: @escaping (MessageId) -> Void,
|
||||
requestStopPollInMessage: @escaping (MessageId) -> Void,
|
||||
updateInputLanguage: @escaping ((String?) -> String?) -> Void,
|
||||
unarchiveChat: @escaping () -> Void,
|
||||
openLinkEditing: @escaping () -> Void,
|
||||
reportPeerIrrelevantGeoLocation: @escaping () -> Void,
|
||||
displaySlowmodeTooltip: @escaping (ASDisplayNode, CGRect) -> Void,
|
||||
displaySendMessageOptions: @escaping (ASDisplayNode, ContextGesture) -> Void,
|
||||
openScheduledMessages: @escaping () -> Void,
|
||||
openPeersNearby: @escaping () -> Void,
|
||||
displaySearchResultsTooltip: @escaping (ASDisplayNode, CGRect) -> Void,
|
||||
unarchivePeer: @escaping () -> Void,
|
||||
statuses: ChatPanelInterfaceInteractionStatuses?
|
||||
) {
|
||||
self.setupReplyMessage = setupReplyMessage
|
||||
self.setupEditMessage = setupEditMessage
|
||||
self.beginMessageSelection = beginMessageSelection
|
||||
@ -191,6 +264,7 @@ final class ChatPanelInterfaceInteraction {
|
||||
self.openScheduledMessages = openScheduledMessages
|
||||
self.openPeersNearby = openPeersNearby
|
||||
self.displaySearchResultsTooltip = displaySearchResultsTooltip
|
||||
self.unarchivePeer = unarchivePeer
|
||||
self.statuses = statuses
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ final class ChatRecentActionsController: TelegramBaseController {
|
||||
}, openScheduledMessages: {
|
||||
}, openPeersNearby: {
|
||||
}, displaySearchResultsTooltip: { _, _ in
|
||||
}, statuses: nil)
|
||||
}, unarchivePeer: {}, statuses: nil)
|
||||
|
||||
self.navigationItem.titleView = self.titleView
|
||||
|
||||
|
@ -16,6 +16,7 @@ private enum ChatReportPeerTitleButton: Equatable {
|
||||
case reportSpam
|
||||
case reportUserSpam
|
||||
case reportIrrelevantGeoLocation
|
||||
case unarchive
|
||||
|
||||
func title(strings: PresentationStrings) -> String {
|
||||
switch self {
|
||||
@ -35,6 +36,8 @@ private enum ChatReportPeerTitleButton: Equatable {
|
||||
return strings.Conversation_ReportSpam
|
||||
case .reportIrrelevantGeoLocation:
|
||||
return strings.Conversation_ReportGroupLocation
|
||||
case .unarchive:
|
||||
return strings.Conversation_Unarchive
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +45,19 @@ private enum ChatReportPeerTitleButton: Equatable {
|
||||
private func peerButtons(_ state: ChatPresentationInterfaceState) -> [ChatReportPeerTitleButton] {
|
||||
var buttons: [ChatReportPeerTitleButton] = []
|
||||
if let peer = state.renderedPeer?.chatMainPeer as? TelegramUser, let contactStatus = state.contactStatus, let peerStatusSettings = contactStatus.peerStatusSettings {
|
||||
if contactStatus.canAddContact && peerStatusSettings.contains(.canAddContact) {
|
||||
if peerStatusSettings.contains(.autoArchived) {
|
||||
if peerStatusSettings.contains(.canBlock) || peerStatusSettings.contains(.canReport) {
|
||||
if peer.isDeleted {
|
||||
buttons.append(.reportUserSpam)
|
||||
} else {
|
||||
if !state.peerIsBlocked {
|
||||
buttons.append(.block)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buttons.append(.unarchive)
|
||||
} else if contactStatus.canAddContact && peerStatusSettings.contains(.canAddContact) {
|
||||
if peerStatusSettings.contains(.canBlock) || peerStatusSettings.contains(.canReport) {
|
||||
if !state.peerIsBlocked {
|
||||
buttons.append(.block)
|
||||
@ -375,12 +390,15 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
}
|
||||
} else {
|
||||
let additionalRightInset: CGFloat = 36.0
|
||||
let areaWidth = width - maxInset * 2.0 - additionalRightInset
|
||||
var areaWidth = width - maxInset * 2.0 - additionalRightInset
|
||||
let maxButtonWidth = floor(areaWidth / CGFloat(self.buttons.count))
|
||||
let buttonSizes = self.buttons.map { button -> CGFloat in
|
||||
return button.1.sizeThatFits(CGSize(width: maxButtonWidth, height: 100.0)).width
|
||||
}
|
||||
let buttonsWidth = buttonSizes.reduce(0.0, +)
|
||||
if buttonsWidth < areaWidth - 20.0 {
|
||||
areaWidth += additionalRightInset
|
||||
}
|
||||
let maxButtonSpacing = floor((areaWidth - buttonsWidth) / CGFloat(self.buttons.count - 1))
|
||||
let buttonSpacing = min(maxButtonSpacing, 110.0)
|
||||
let updatedButtonsWidth = buttonsWidth + CGFloat(self.buttons.count - 1) * buttonSpacing
|
||||
@ -469,6 +487,8 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
self.interfaceInteraction?.shareAccountContact()
|
||||
case .block, .reportSpam, .reportUserSpam:
|
||||
self.interfaceInteraction?.reportPeer()
|
||||
case .unarchive:
|
||||
self.interfaceInteraction?.unarchivePeer()
|
||||
case .addContact:
|
||||
self.interfaceInteraction?.presentPeerContact()
|
||||
case .reportIrrelevantGeoLocation:
|
||||
|
@ -416,7 +416,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode {
|
||||
}, openScheduledMessages: {
|
||||
}, openPeersNearby: {
|
||||
}, displaySearchResultsTooltip: { _, _ in
|
||||
}, statuses: nil)
|
||||
}, unarchivePeer: {}, statuses: nil)
|
||||
|
||||
self.selectionPanel.interfaceInteraction = interfaceInteraction
|
||||
|
||||
|
@ -550,7 +550,7 @@ public class PeerMediaCollectionController: TelegramBaseController {
|
||||
}, openScheduledMessages: {
|
||||
}, openPeersNearby: {
|
||||
}, displaySearchResultsTooltip: { _, _ in
|
||||
}, statuses: nil)
|
||||
}, unarchivePeer: {}, statuses: nil)
|
||||
|
||||
self.updateInterfaceState(animated: false, { return $0 })
|
||||
|
||||
|
Binary file not shown.
@ -449,12 +449,12 @@ public final class WalletStrings: Equatable {
|
||||
public var Wallet_SecureStorageReset_Title: String { return self._s[219]! }
|
||||
public var Wallet_Receive_CommentHeader: String { return self._s[220]! }
|
||||
public var Wallet_Info_ReceiveGrams: String { return self._s[221]! }
|
||||
public func Wallet_Updated_MinutesAgo(_ value: Int32) -> String {
|
||||
public func Wallet_Updated_HoursAgo(_ value: Int32) -> String {
|
||||
let form = getPluralizationForm(self.lc, value)
|
||||
let stringValue = walletStringsFormattedNumber(value, self.groupingSeparator)
|
||||
return String(format: self._ps[0 * 6 + Int(form.rawValue)]!, stringValue)
|
||||
}
|
||||
public func Wallet_Updated_HoursAgo(_ value: Int32) -> String {
|
||||
public func Wallet_Updated_MinutesAgo(_ value: Int32) -> String {
|
||||
let form = getPluralizationForm(self.lc, value)
|
||||
let stringValue = walletStringsFormattedNumber(value, self.groupingSeparator)
|
||||
return String(format: self._ps[1 * 6 + Int(form.rawValue)]!, stringValue)
|
||||
|
Loading…
x
Reference in New Issue
Block a user