UI improvements

This commit is contained in:
Ali 2023-03-02 19:05:19 +04:00
parent 98c0b7234c
commit 274aa510b1
5 changed files with 52 additions and 11 deletions

View File

@ -433,7 +433,7 @@ public final class EngineMessageReactionListContext {
self.reaction = reaction self.reaction = reaction
let initialState = EngineMessageReactionListContext.State(message: message, readStats: readStats, reaction: reaction) let initialState = EngineMessageReactionListContext.State(message: message, readStats: readStats, reaction: reaction)
self.state = InternalState(hasOutgoingReaction: initialState.hasOutgoingReaction, totalCount: initialState.totalCount, items: initialState.items, canLoadMore: true, nextOffset: nil) self.state = InternalState(hasOutgoingReaction: initialState.hasOutgoingReaction, totalCount: initialState.totalCount, items: initialState.items, canLoadMore: initialState.canLoadMore, nextOffset: nil)
if initialState.canLoadMore { if initialState.canLoadMore {
self.loadMore() self.loadMore()

View File

@ -512,14 +512,16 @@ private final class SendInviteLinkScreenComponent: Component {
if self.selectedItems.isEmpty { if self.selectedItems.isEmpty {
controller.dismiss() controller.dismiss()
} else if let link = component.link { } else if let link = component.link {
let selectedPeers = component.peers.filter { self.selectedItems.contains($0.id) }
let _ = enqueueMessagesToMultiplePeers(account: component.context.account, peerIds: Array(self.selectedItems), threadIds: [:], messages: [.message(text: link, attributes: [], inlineStickers: [:], mediaReference: nil, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]).start() let _ = enqueueMessagesToMultiplePeers(account: component.context.account, peerIds: Array(self.selectedItems), threadIds: [:], messages: [.message(text: link, attributes: [], inlineStickers: [:], mediaReference: nil, replyToMessageId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]).start()
let text: String let text: String
if component.peers.count == 1 { if selectedPeers.count == 1 {
text = environment.strings.Conversation_ShareLinkTooltip_Chat_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string text = environment.strings.Conversation_ShareLinkTooltip_Chat_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string
} else if component.peers.count == 2 { } else if selectedPeers.count == 2 {
text = environment.strings.Conversation_ShareLinkTooltip_TwoChats_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), component.peers[1].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string text = environment.strings.Conversation_ShareLinkTooltip_TwoChats_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), selectedPeers[1].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: "")).string
} else { } else {
text = environment.strings.Conversation_ShareLinkTooltip_ManyChats_One(component.peers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), "\(component.peers.count - 1)").string text = environment.strings.Conversation_ShareLinkTooltip_ManyChats_One(selectedPeers[0].displayTitle(strings: environment.strings, displayOrder: .firstLast).replacingOccurrences(of: "*", with: ""), "\(selectedPeers.count - 1)").string
} }
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }

View File

@ -2258,7 +2258,7 @@ final class StorageUsageScreenComponent: Component {
} }
let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }
controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .window(.root)) controller.present(UndoOverlayController(presentationData: presentationData, content: .succeed(text: presentationData.strings.ClearCache_Success("\(dataSizeString(size, formatting: DataSizeStringFormatting(presentationData: presentationData)))", stringForDeviceType()).string), elevatedLayout: false, action: { _ in return false }), in: .current)
} }
private func reloadStats(firstTime: Bool, completion: @escaping () -> Void) { private func reloadStats(firstTime: Bool, completion: @escaping () -> Void) {

View File

@ -637,6 +637,8 @@ public final class SharedAccountContextImpl: SharedAccountContext {
if hadUpdates { if hadUpdates {
self.activeAccountsValue!.accounts.sort(by: { $0.2 < $1.2 }) self.activeAccountsValue!.accounts.sort(by: { $0.2 < $1.2 })
self.activeAccountsPromise.set(.single(self.activeAccountsValue!)) self.activeAccountsPromise.set(.single(self.activeAccountsValue!))
self.performAccountSettingsImportIfNecessary()
} }
if self.activeAccountsValue!.primary == nil && self.activeAccountsValue!.currentAuth == nil { if self.activeAccountsValue!.primary == nil && self.activeAccountsValue!.currentAuth == nil {
@ -897,6 +899,37 @@ public final class SharedAccountContextImpl: SharedAccountContext {
self.callStateDisposable?.dispose() self.callStateDisposable?.dispose()
} }
private var didPerformAccountSettingsImport = false
private func performAccountSettingsImportIfNecessary() {
if self.didPerformAccountSettingsImport {
return
}
if let _ = UserDefaults.standard.value(forKey: "didPerformAccountSettingsImport") {
self.didPerformAccountSettingsImport = true
return
}
UserDefaults.standard.set(true as NSNumber, forKey: "didPerformAccountSettingsImport")
UserDefaults.standard.synchronize()
if let primary = self.activeAccountsValue?.primary {
let _ = (primary.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: primary.account.peerId))
|> deliverOnMainQueue).start(next: { [weak self] peer in
guard let self, case let .user(user) = peer else {
return
}
if user.isPremium {
let _ = updateMediaDownloadSettingsInteractively(accountManager: self.accountManager, { settings in
var settings = settings
settings.energyUsageSettings.loopEmoji = true
return settings
}).start()
}
})
}
self.didPerformAccountSettingsImport = true
}
private func updateAccountBackupData(account: Account) -> Signal<Never, NoError> { private func updateAccountBackupData(account: Account) -> Signal<Never, NoError> {
return accountBackupData(postbox: account.postbox) return accountBackupData(postbox: account.postbox)
|> mapToSignal { backupData -> Signal<Never, NoError> in |> mapToSignal { backupData -> Signal<Never, NoError> in

View File

@ -270,18 +270,24 @@ public struct EnergyUsageSettings: Codable, Equatable {
case autodownloadInBackground case autodownloadInBackground
} }
public static var `default`: EnergyUsageSettings { public static let `default`: EnergyUsageSettings = {
var length: Int = 4
var cpuCount: UInt32 = 0
sysctlbyname("hw.ncpu", &cpuCount, &length, nil, 0)
let isCapable = cpuCount >= 4
return EnergyUsageSettings( return EnergyUsageSettings(
activationThreshold: 15, activationThreshold: 15,
autoplayVideo: true, autoplayVideo: true,
autoplayGif: true, autoplayGif: true,
loopStickers: true, loopStickers: true,
loopEmoji: true, loopEmoji: isCapable ? false : true,
fullTranslucency: true, fullTranslucency: isCapable ? false : true,
extendBackgroundWork: true, extendBackgroundWork: true,
autodownloadInBackground: true autodownloadInBackground: true
) )
} }()
public static var powerSavingDefault: EnergyUsageSettings { public static var powerSavingDefault: EnergyUsageSettings {
return EnergyUsageSettings( return EnergyUsageSettings(