mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
WIP
This commit is contained in:
parent
5880268293
commit
ec6d48dd5a
@ -1638,7 +1638,10 @@ public final class ChatListNode: ListView {
|
|||||||
} else {
|
} else {
|
||||||
self.push?(NewSessionInfoScreen(context: self.context, newSessionReview: newSessionReview))
|
self.push?(NewSessionInfoScreen(context: self.context, newSessionReview: newSessionReview))
|
||||||
|
|
||||||
|
//#if DEBUG
|
||||||
|
//#else
|
||||||
let _ = self.context.engine.privacy.terminateAnotherSession(id: newSessionReview.id).start()
|
let _ = self.context.engine.privacy.terminateAnotherSession(id: newSessionReview.id).start()
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}, openChatFolderUpdates: { [weak self] in
|
}, openChatFolderUpdates: { [weak self] in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
|
@ -143,6 +143,10 @@ public final class NavigationBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
public var effectView: UIVisualEffectView?
|
public var effectView: UIVisualEffectView?
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
|
|
||||||
|
public var backgroundView: UIView {
|
||||||
|
return self.backgroundNode.view
|
||||||
|
}
|
||||||
|
|
||||||
private var validLayout: (CGSize, CGFloat)?
|
private var validLayout: (CGSize, CGFloat)?
|
||||||
|
|
||||||
|
@ -757,6 +757,10 @@ public extension CALayer {
|
|||||||
static func blur() -> NSObject? {
|
static func blur() -> NSObject? {
|
||||||
return makeBlurFilter()
|
return makeBlurFilter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func luminanceToAlpha() -> NSObject? {
|
||||||
|
return makeLuminanceToAlphaFilter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension CALayer {
|
public extension CALayer {
|
||||||
|
@ -151,6 +151,7 @@ final class ReactionContextBackgroundNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.backgroundView.updateColor(color: theme.contextMenu.backgroundColor, transition: .immediate)
|
self.backgroundView.updateColor(color: theme.contextMenu.backgroundColor, transition: .immediate)
|
||||||
|
//self.backgroundView.updateColor(color: UIColor(white: 1.0, alpha: 0.0), forceKeepBlur: true, transition: .immediate)
|
||||||
|
|
||||||
let shadowColor = UIColor(white: 0.0, alpha: 0.4)
|
let shadowColor = UIColor(white: 0.0, alpha: 0.4)
|
||||||
|
|
||||||
|
96
submodules/TelegramCore/Sources/State/ChannelBoost.swift
Normal file
96
submodules/TelegramCore/Sources/State/ChannelBoost.swift
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import Foundation
|
||||||
|
import TelegramApi
|
||||||
|
import Postbox
|
||||||
|
import SwiftSignalKit
|
||||||
|
|
||||||
|
public final class ChannelBoostStatus: Equatable {
|
||||||
|
public let level: Int
|
||||||
|
public let boosts: Int
|
||||||
|
public let nextLevelBoosts: Int?
|
||||||
|
|
||||||
|
public init(level: Int, boosts: Int, nextLevelBoosts: Int?) {
|
||||||
|
self.level = level
|
||||||
|
self.boosts = boosts
|
||||||
|
self.nextLevelBoosts = nextLevelBoosts
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func ==(lhs: ChannelBoostStatus, rhs: ChannelBoostStatus) -> Bool {
|
||||||
|
if lhs.level != rhs.level {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if lhs.boosts != rhs.boosts {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if lhs.nextLevelBoosts != rhs.nextLevelBoosts {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func _internal_getBoostStatus(account: Account, peerId: PeerId) -> Signal<ChannelBoostStatus?, NoError> {
|
||||||
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
|
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||||
|
}
|
||||||
|
|> mapToSignal { inputPeer -> Signal<ChannelBoostStatus?, NoError> in
|
||||||
|
guard let inputPeer = inputPeer else {
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
return account.network.request(Api.functions.stories.getBoostsStatus(peer: inputPeer))
|
||||||
|
|> map(Optional.init)
|
||||||
|
|> `catch` { _ -> Signal<Api.stories.BoostsStatus?, NoError> in
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
|> map { result -> ChannelBoostStatus? in
|
||||||
|
guard let result = result else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch result {
|
||||||
|
case let .boostsStatus(_, level, boosts, nextLevelBoosts):
|
||||||
|
return ChannelBoostStatus(level: Int(level), boosts: Int(boosts), nextLevelBoosts: nextLevelBoosts.flatMap(Int.init))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CanApplyBoostStatus {
|
||||||
|
case ok
|
||||||
|
case replace(currentBoost: EnginePeer)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _internal_canApplyBoost(account: Account, peerId: PeerId) -> Signal<CanApplyBoostStatus?, NoError> {
|
||||||
|
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||||
|
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||||
|
}
|
||||||
|
|> mapToSignal { inputPeer -> Signal<CanApplyBoostStatus?, NoError> in
|
||||||
|
guard let inputPeer = inputPeer else {
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
return account.network.request(Api.functions.stories.canApplyBoost(peer: inputPeer))
|
||||||
|
|> map(Optional.init)
|
||||||
|
|> `catch` { _ -> Signal<Api.stories.CanApplyBoostResult?, NoError> in
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
|> mapToSignal { result -> Signal<CanApplyBoostStatus?, NoError> in
|
||||||
|
guard let result = result else {
|
||||||
|
return .single(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
return account.postbox.transaction { transaction -> CanApplyBoostStatus? in
|
||||||
|
switch result {
|
||||||
|
case .canApplyBoostOk:
|
||||||
|
return .ok
|
||||||
|
case let .canApplyBoostReplace(currentBoost, chats):
|
||||||
|
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: []))
|
||||||
|
|
||||||
|
if let peer = transaction.getPeer(currentBoost.peerId) {
|
||||||
|
return .replace(currentBoost: EnginePeer(peer))
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1281,7 +1281,7 @@ public enum StoriesUploadAvailability {
|
|||||||
case unknownLimit
|
case unknownLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
func _internal_checkStoriesUploadAvailability(account: Account) -> Signal<StoriesUploadAvailability, NoError> {
|
func _internal_checkStoriesUploadAvailability(account: Account, target: Stories.PendingTarget) -> Signal<StoriesUploadAvailability, NoError> {
|
||||||
return account.network.request(Api.functions.stories.canSendStory(peer: .inputPeerSelf))
|
return account.network.request(Api.functions.stories.canSendStory(peer: .inputPeerSelf))
|
||||||
|> map { result -> StoriesUploadAvailability in
|
|> map { result -> StoriesUploadAvailability in
|
||||||
if result == .boolTrue {
|
if result == .boolTrue {
|
||||||
|
@ -1213,8 +1213,8 @@ public extension TelegramEngine {
|
|||||||
return _internal_editStoryPrivacy(account: self.account, id: id, privacy: privacy)
|
return _internal_editStoryPrivacy(account: self.account, id: id, privacy: privacy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func checkStoriesUploadAvailability() -> Signal<StoriesUploadAvailability, NoError> {
|
public func checkStoriesUploadAvailability(target: Stories.PendingTarget) -> Signal<StoriesUploadAvailability, NoError> {
|
||||||
return _internal_checkStoriesUploadAvailability(account: self.account)
|
return _internal_checkStoriesUploadAvailability(account: self.account, target: target)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteStories(peerId: EnginePeer.Id, ids: [Int32]) -> Signal<Never, NoError> {
|
public func deleteStories(peerId: EnginePeer.Id, ids: [Int32]) -> Signal<Never, NoError> {
|
||||||
|
@ -2410,7 +2410,7 @@ public class CameraScreen: ViewController {
|
|||||||
|
|
||||||
self.requestAudioSession()
|
self.requestAudioSession()
|
||||||
|
|
||||||
self.postingAvailabilityPromise.set(self.context.engine.messages.checkStoriesUploadAvailability())
|
self.postingAvailabilityPromise.set(self.context.engine.messages.checkStoriesUploadAvailability(target: .myStories))
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder: NSCoder) {
|
required public init(coder: NSCoder) {
|
||||||
|
@ -26,3 +26,4 @@ void applySmoothRoundedCornersImpl(CALayer * _Nonnull layer);
|
|||||||
UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition);
|
UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition);
|
||||||
|
|
||||||
NSObject * _Nullable makeBlurFilter();
|
NSObject * _Nullable makeBlurFilter();
|
||||||
|
NSObject * _Nullable makeLuminanceToAlphaFilter();
|
||||||
|
@ -210,3 +210,7 @@ UIView<UIKitPortalViewProtocol> * _Nullable makePortalView(bool matchPosition) {
|
|||||||
NSObject * _Nullable makeBlurFilter() {
|
NSObject * _Nullable makeBlurFilter() {
|
||||||
return [(id<GraphicsFilterProtocol>)NSClassFromString(@"CAFilter") filterWithName:@"gaussianBlur"];
|
return [(id<GraphicsFilterProtocol>)NSClassFromString(@"CAFilter") filterWithName:@"gaussianBlur"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSObject * _Nullable makeLuminanceToAlphaFilter() {
|
||||||
|
return [(id<GraphicsFilterProtocol>)NSClassFromString(@"CAFilter") filterWithName:@"luminanceToAlpha"];
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user