This commit is contained in:
Ali 2023-07-12 23:52:56 +04:00
parent ca8555c070
commit ff9157fef4
3 changed files with 209 additions and 191 deletions

View File

@ -265,6 +265,7 @@
"PUSH_STORY_NOTEXT" = "%1$@|posted a story"; "PUSH_STORY_NOTEXT" = "%1$@|posted a story";
"PUSH_MESSAGE_STORY" = "%1$@|shared a story with you"; "PUSH_MESSAGE_STORY" = "%1$@|shared a story with you";
"PUSH_MESSAGE_STORY_MENTION" = "%1$@|mentioned you in a story";
"PUSH_CHANNEL_MESSAGE_STORY" = "%1$@|shared a story"; "PUSH_CHANNEL_MESSAGE_STORY" = "%1$@|shared a story";
"PUSH_CHAT_MESSAGE_STORY" = "%2$@|%1$@ shared a story to the group"; "PUSH_CHAT_MESSAGE_STORY" = "%2$@|%1$@ shared a story to the group";

View File

@ -629,9 +629,10 @@ public extension TelegramEngine {
}).start() }).start()
} }
public func storySubscriptions(isHidden: Bool) -> Signal<EngineStorySubscriptions, NoError> { public func storySubscriptions(isHidden: Bool, tempKeepNewlyArchived: Bool = false) -> Signal<EngineStorySubscriptions, NoError> {
return `deferred` { () -> Signal<EngineStorySubscriptions, NoError> in
let debugTimerSignal: Signal<Bool, NoError> let debugTimerSignal: Signal<Bool, NoError>
#if DEBUG && false #if DEBUG && false
debugTimerSignal = Signal<Bool, NoError>.single(true) debugTimerSignal = Signal<Bool, NoError>.single(true)
|> then( |> then(
Signal<Bool, NoError>.single(true) Signal<Bool, NoError>.single(true)
@ -642,9 +643,11 @@ public extension TelegramEngine {
) )
|> restart |> restart
) )
#else #else
debugTimerSignal = .single(true) debugTimerSignal = .single(true)
#endif #endif
let previousIdList = Atomic<Set<PeerId>>(value: Set())
let subscriptionsKey: PostboxStorySubscriptionsKey = isHidden ? .hidden : .filtered let subscriptionsKey: PostboxStorySubscriptionsKey = isHidden ? .hidden : .filtered
@ -678,6 +681,19 @@ public extension TelegramEngine {
subscriptionPeerIds.removeAll() subscriptionPeerIds.removeAll()
} }
if tempKeepNewlyArchived {
let updatedList = previousIdList.modify { list in
var list = list
list.formUnion(subscriptionPeerIds)
return list
}
for id in updatedList {
if !subscriptionPeerIds.contains(id) {
subscriptionPeerIds.append(id)
}
}
}
additionalDataKeys.append(contentsOf: subscriptionPeerIds.map { peerId -> PostboxViewKey in additionalDataKeys.append(contentsOf: subscriptionPeerIds.map { peerId -> PostboxViewKey in
return PostboxViewKey.storyItems(peerId: peerId) return PostboxViewKey.storyItems(peerId: peerId)
}) })
@ -847,6 +863,7 @@ public extension TelegramEngine {
} }
} }
} }
}
public func preloadStorySubscriptions(isHidden: Bool) -> Signal<[EngineMedia.Id: StoryPreloadInfo], NoError> { public func preloadStorySubscriptions(isHidden: Bool) -> Signal<[EngineMedia.Id: StoryPreloadInfo], NoError> {
let basicPeerKey = PostboxViewKey.basicPeer(self.account.peerId) let basicPeerKey = PostboxViewKey.basicPeer(self.account.peerId)

View File

@ -553,7 +553,7 @@ public final class StoryContentContextImpl: StoryContentContext {
self.updatePeerContexts() self.updatePeerContexts()
}) })
} else { } else {
self.storySubscriptionsDisposable = (context.engine.messages.storySubscriptions(isHidden: isHidden) self.storySubscriptionsDisposable = (context.engine.messages.storySubscriptions(isHidden: isHidden, tempKeepNewlyArchived: true)
|> deliverOnMainQueue).start(next: { [weak self] storySubscriptions in |> deliverOnMainQueue).start(next: { [weak self] storySubscriptions in
guard let self else { guard let self else {
return return