[WIP] Stories

This commit is contained in:
Ali 2023-06-09 16:04:42 +04:00
parent 9b7e421107
commit 7015298cd5
3 changed files with 26 additions and 5 deletions

View File

@ -839,6 +839,9 @@ public final class PeerExpiringStoryListContext {
private var pollDisposable: Disposable?
private let statePromise = Promise<State>()
var state: Signal<State, NoError> {
return self.statePromise.get()
}
init(queue: Queue, account: Account, peerId: EnginePeer.Id) {
self.queue = queue
@ -1034,6 +1037,12 @@ public final class PeerExpiringStoryListContext {
private let queue: Queue
private let impl: QueueLocalObject<Impl>
public var state: Signal<State, NoError> {
return impl.signalWith { impl, subscriber in
return impl.state.start(next: subscriber.putNext)
}
}
public init(account: Account, peerId: EnginePeer.Id) {
let queue = Queue.mainQueue()
self.queue = queue

View File

@ -472,6 +472,19 @@ public final class StoryItemSetContainerComponent: Component {
return super.hitTest(point, with: event)
}
private func isProgressPaused() -> Bool {
guard let component = self.component else {
return false
}
if self.inputPanelExternalState.isEditing || component.isProgressPaused || self.displayReactions || self.actionSheet != nil || self.contextController != nil || self.sendMessageContext.audioRecorderValue != nil || self.sendMessageContext.videoRecorderValue != nil || self.displayViewList {
return true
}
if let captionItem = self.captionItem, captionItem.externalState.expandFraction > 0.0 {
return true
}
return false
}
private func updateScrolling(transition: Transition) {
guard let component = self.component, let itemLayout = self.itemLayout else {
return
@ -535,7 +548,7 @@ public final class StoryItemSetContainerComponent: Component {
itemTransition.setFrame(view: view, frame: CGRect(origin: CGPoint(), size: itemLayout.size))
if let view = view as? StoryContentItem.View {
view.setIsProgressPaused(self.inputPanelExternalState.isEditing || component.isProgressPaused || self.displayReactions || self.actionSheet != nil || self.contextController != nil || self.sendMessageContext.audioRecorderValue != nil || self.sendMessageContext.videoRecorderValue != nil || self.displayViewList)
view.setIsProgressPaused(self.isProgressPaused())
}
}
@ -554,13 +567,10 @@ public final class StoryItemSetContainerComponent: Component {
}
func updateIsProgressPaused() {
guard let component = self.component else {
return
}
for (_, visibleItem) in self.visibleItems {
if let view = visibleItem.view.view {
if let view = view as? StoryContentItem.View {
view.setIsProgressPaused(self.inputPanelExternalState.isEditing || component.isProgressPaused || self.displayReactions || self.actionSheet != nil || self.contextController != nil || self.sendMessageContext.audioRecorderValue != nil || self.sendMessageContext.videoRecorderValue != nil || self.displayViewList || self.isEditingStory)
view.setIsProgressPaused(self.isProgressPaused())
}
}
}

View File

@ -401,9 +401,11 @@ func keepPeerInfoScreenDataHot(context: AccountContext, peerId: PeerId, chatLoca
if case .user = inputData {
signals.append(Signal { _ in
let listContext = PeerStoryListContext(account: context.account, peerId: peerId, isArchived: false)
let expiringListContext = PeerExpiringStoryListContext(account: context.account, peerId: peerId)
return ActionDisposable {
let _ = listContext
let _ = expiringListContext
}
})
}