mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Ensure story subscriptions are cached
This commit is contained in:
parent
d0fd3561d9
commit
b4475f2d91
@ -1166,6 +1166,24 @@ public func _internal_pollPeerStories(postbox: Postbox, network: Network, accoun
|
||||
}
|
||||
|
||||
transaction.setStoryItems(peerId: peerId, items: updatedPeerEntries)
|
||||
|
||||
if !updatedPeerEntries.isEmpty {
|
||||
if let user = transaction.getPeer(peerId) as? TelegramUser, let storiesHidden = user.storiesHidden {
|
||||
if storiesHidden {
|
||||
if !transaction.storySubscriptionsContains(key: .hidden, peerId: peerId) {
|
||||
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .hidden)
|
||||
peerIds.append(peerId)
|
||||
transaction.replaceAllStorySubscriptions(key: .hidden, state: state, peerIds: peerIds)
|
||||
}
|
||||
} else {
|
||||
if !transaction.storySubscriptionsContains(key: .filtered, peerId: peerId) {
|
||||
var (state, peerIds) = transaction.getAllStorySubscriptions(key: .filtered)
|
||||
peerIds.append(peerId)
|
||||
transaction.replaceAllStorySubscriptions(key: .filtered, state: state, peerIds: peerIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
@ -179,16 +179,6 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
return true
|
||||
}
|
||||
|
||||
final class ScrollView: UIScrollView {
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
return super.hitTest(point, with: event)
|
||||
}
|
||||
|
||||
override func touchesShouldCancel(in view: UIView) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
struct ItemLayout {
|
||||
var size: CGSize
|
||||
|
||||
@ -234,11 +224,9 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
public final class View: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
||||
public final class View: UIView, UIGestureRecognizerDelegate {
|
||||
let sendMessageContext: StoryItemSetContainerSendMessage
|
||||
|
||||
let scrollView: ScrollView
|
||||
|
||||
let contentContainerView: UIView
|
||||
let topContentGradientLayer: SimpleGradientLayer
|
||||
let bottomContentGradientLayer: SimpleGradientLayer
|
||||
@ -297,8 +285,6 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
override init(frame: CGRect) {
|
||||
self.sendMessageContext = StoryItemSetContainerSendMessage()
|
||||
|
||||
self.scrollView = ScrollView()
|
||||
|
||||
self.contentContainerView = UIView()
|
||||
self.contentContainerView.clipsToBounds = true
|
||||
if #available(iOS 13.0, *) {
|
||||
@ -318,23 +304,6 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.scrollView.delaysContentTouches = false
|
||||
self.scrollView.canCancelContentTouches = true
|
||||
self.scrollView.clipsToBounds = false
|
||||
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
|
||||
self.scrollView.contentInsetAdjustmentBehavior = .never
|
||||
}
|
||||
if #available(iOS 13.0, *) {
|
||||
self.scrollView.automaticallyAdjustsScrollIndicatorInsets = false
|
||||
}
|
||||
self.scrollView.showsVerticalScrollIndicator = false
|
||||
self.scrollView.showsHorizontalScrollIndicator = false
|
||||
self.scrollView.alwaysBounceHorizontal = false
|
||||
self.scrollView.alwaysBounceVertical = true
|
||||
self.scrollView.scrollsToTop = false
|
||||
self.scrollView.delegate = self
|
||||
self.scrollView.clipsToBounds = true
|
||||
|
||||
self.addSubview(self.contentContainerView)
|
||||
self.contentContainerView.addSubview(self.contentDimView)
|
||||
self.contentContainerView.layer.addSublayer(self.topContentGradientLayer)
|
||||
@ -443,7 +412,7 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
}
|
||||
|
||||
func isPointInsideContentArea(point: CGPoint) -> Bool {
|
||||
if let inputPanelView = self.inputPanel.view {
|
||||
if let inputPanelView = self.inputPanel.view, inputPanelView.alpha != 0.0 {
|
||||
if inputPanelView.frame.contains(point) {
|
||||
return false
|
||||
}
|
||||
@ -542,15 +511,6 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
component.close()
|
||||
}
|
||||
|
||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
if !self.ignoreScrolling {
|
||||
self.updateScrolling(transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
|
||||
}
|
||||
|
||||
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
if let inputView = self.inputPanel.view, let inputViewHitTest = inputView.hitTest(self.convert(point, to: inputView), with: event) {
|
||||
return inputViewHitTest
|
||||
@ -2312,13 +2272,6 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
transition.setAlpha(view: self.contentDimView, alpha: dimAlpha)
|
||||
}
|
||||
|
||||
self.ignoreScrolling = true
|
||||
transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: availableSize.width, height: availableSize.height)))
|
||||
let scrollContentSize = availableSize
|
||||
if scrollContentSize != self.scrollView.contentSize {
|
||||
self.scrollView.contentSize = scrollContentSize
|
||||
}
|
||||
self.ignoreScrolling = false
|
||||
self.updateScrolling(transition: transition)
|
||||
|
||||
if let focusedItem, let visibleItem = self.visibleItems[focusedItem.storyItem.id], let index = focusedItem.position {
|
||||
|
Loading…
x
Reference in New Issue
Block a user