Web app improvements

This commit is contained in:
Ilya Laktyushin
2024-07-02 21:03:22 +04:00
parent 613bba57c2
commit f5092b8d8d
33 changed files with 1483 additions and 1306 deletions

View File

@@ -188,7 +188,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
private let bannedSendPhotos: (Int32, Bool)?
private let bannedSendVideos: (Int32, Bool)?
private let canBoostToUnrestrict: Bool
private let paidMediaAllowed: Bool
fileprivate let paidMediaAllowed: Bool
private let subject: Subject
private let saveEditedPhotos: Bool
@@ -2207,7 +2207,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
})
}
private var selectionCount: Int32 = 0
fileprivate var selectionCount: Int32 = 0
fileprivate func updateSelectionState(count: Int32) {
self.selectionCount = count
@@ -2667,6 +2667,45 @@ final class MediaPickerContext: AttachmentMediaPickerContext {
return isForcedCaption
}
var canMakePaidContent: Bool {
guard let controller = self.controller else {
return false
}
var isPaidAvailable = false
if controller.paidMediaAllowed && controller.selectionCount <= 10 {
isPaidAvailable = true
}
return isPaidAvailable
}
var price: Int64? {
guard let controller = self.controller else {
return nil
}
var price: Int64?
if let selectionContext = controller.interaction?.selectionState, let editingContext = controller.interaction?.editingState {
for case let item as TGMediaEditableItem in selectionContext.selectedItems() {
if price == nil, let itemPrice = editingContext.price(for: item) as? Int64 {
price = itemPrice
break
}
}
}
return price
}
func setPrice(_ price: Int64) {
guard let controller = self.controller else {
return
}
if let selectionContext = controller.interaction?.selectionState, let editingContext = controller.interaction?.editingState {
selectionContext.selectionLimit = 10
for case let item as TGMediaEditableItem in selectionContext.selectedItems() {
editingContext.setPrice(NSNumber(value: price), for: item)
}
}
}
var captionIsAboveMedia: Signal<Bool, NoError> {
return Signal { [weak self] subscriber in
guard let interaction = self?.controller?.interaction else {