mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-03 18:13:41 +00:00
no message
This commit is contained in:
@@ -579,6 +579,13 @@ public final class MediaBox {
|
||||
}
|
||||
}
|
||||
|
||||
public func storeCachedResourceRepresentation(_ resource: MediaResource, representation: CachedMediaResourceRepresentation, data: Data) {
|
||||
self.dataQueue.async {
|
||||
let path = self.cachedRepresentationPathForId(resource.id, representation: representation)
|
||||
let _ = try? data.write(to: URL(fileURLWithPath: path))
|
||||
}
|
||||
}
|
||||
|
||||
public func cachedResourceRepresentation(_ resource: MediaResource, representation: CachedMediaResourceRepresentation, complete: Bool) -> Signal<MediaResourceData, NoError> {
|
||||
return Signal { subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
||||
@@ -1614,7 +1614,7 @@ public final class MessageHistoryView {
|
||||
if !entries.isEmpty && mutableView.clipHoles {
|
||||
var referenceIndex = entries.count - 1
|
||||
for i in 0 ..< entries.count {
|
||||
if self.anchorIndex.isLess(than: entries[i].index) {
|
||||
if self.anchorIndex.isLessOrEqual(to: entries[i].index) {
|
||||
referenceIndex = i
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
import Foundation
|
||||
|
||||
final class MutablePeerNotificationSettingsView: MutablePostboxView {
|
||||
let peerId: PeerId
|
||||
var notificationSettings: PeerNotificationSettings?
|
||||
let peerIds: Set<PeerId>
|
||||
var notificationSettings: [PeerId: PeerNotificationSettings]
|
||||
|
||||
init(postbox: Postbox, peerId: PeerId) {
|
||||
self.peerId = peerId
|
||||
self.notificationSettings = postbox.peerNotificationSettingsTable.getEffective(peerId)
|
||||
init(postbox: Postbox, peerIds: Set<PeerId>) {
|
||||
self.peerIds = peerIds
|
||||
self.notificationSettings = [:]
|
||||
for peerId in peerIds {
|
||||
if let settings = postbox.peerNotificationSettingsTable.getEffective(peerId) {
|
||||
self.notificationSettings[peerId] = settings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
|
||||
if let notificationSettings = transaction.currentUpdatedPeerNotificationSettings[self.peerId] {
|
||||
self.notificationSettings = notificationSettings
|
||||
return true
|
||||
if !transaction.currentUpdatedPeerNotificationSettings.isEmpty {
|
||||
var updated = false
|
||||
for peerId in self.peerIds {
|
||||
if let settings = transaction.currentUpdatedPeerNotificationSettings[peerId] {
|
||||
self.notificationSettings[peerId] = settings
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
return updated
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
@@ -24,11 +35,11 @@ final class MutablePeerNotificationSettingsView: MutablePostboxView {
|
||||
}
|
||||
|
||||
public final class PeerNotificationSettingsView: PostboxView {
|
||||
public let peerId: PeerId
|
||||
public let notificationSettings: PeerNotificationSettings?
|
||||
public let peerIds: Set<PeerId>
|
||||
public let notificationSettings: [PeerId: PeerNotificationSettings]
|
||||
|
||||
init(_ view: MutablePeerNotificationSettingsView) {
|
||||
self.peerId = view.peerId
|
||||
self.peerIds = view.peerIds
|
||||
self.notificationSettings = view.notificationSettings
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
import Foundation
|
||||
|
||||
public struct PeerViewComponents: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let cachedData = PeerViewComponents(rawValue: 1 << 0)
|
||||
public static let subPeers = PeerViewComponents(rawValue: 1 << 1)
|
||||
public static let messages = PeerViewComponents(rawValue: 1 << 2)
|
||||
|
||||
public static let all: PeerViewComponents = [.cachedData, .subPeers, .messages]
|
||||
}
|
||||
|
||||
final class MutablePeerView: MutablePostboxView {
|
||||
let peerId: PeerId
|
||||
let components: PeerViewComponents
|
||||
var notificationSettings: PeerNotificationSettings?
|
||||
var cachedData: CachedPeerData?
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
@@ -9,7 +24,8 @@ final class MutablePeerView: MutablePostboxView {
|
||||
var messages: [MessageId: Message] = [:]
|
||||
var peerIsContact: Bool
|
||||
|
||||
init(postbox: Postbox, peerId: PeerId) {
|
||||
init(postbox: Postbox, peerId: PeerId, components: PeerViewComponents) {
|
||||
self.components = components
|
||||
let cachedData = postbox.cachedPeerDataTable.get(peerId)
|
||||
let peerIsContact = postbox.contactsTable.isContact(peerId: peerId)
|
||||
|
||||
|
||||
@@ -2773,7 +2773,7 @@ public final class Postbox {
|
||||
|
||||
public func peerView(id: PeerId) -> Signal<PeerView, NoError> {
|
||||
return self.transactionSignal { subscriber, transaction in
|
||||
let view = MutablePeerView(postbox: self, peerId: id)
|
||||
let view = MutablePeerView(postbox: self, peerId: id, components: .all)
|
||||
let (index, signal) = self.viewTracker.addPeerView(view)
|
||||
|
||||
subscriber.putNext(PeerView(view))
|
||||
|
||||
@@ -22,7 +22,7 @@ private enum MutableUnreadMessageCountsItemEntry {
|
||||
case group(PeerGroupId, ChatListGroupReferenceUnreadCounters)
|
||||
}
|
||||
|
||||
enum UnreadMessageCountsItemEntry {
|
||||
public enum UnreadMessageCountsItemEntry {
|
||||
case total(ChatListTotalUnreadState)
|
||||
case peer(PeerId, Int32)
|
||||
case group(PeerGroupId, Int32)
|
||||
@@ -88,7 +88,7 @@ final class MutableUnreadMessageCountsView: MutablePostboxView {
|
||||
}
|
||||
|
||||
public final class UnreadMessageCountsView: PostboxView {
|
||||
private let entries: [UnreadMessageCountsItemEntry]
|
||||
public let entries: [UnreadMessageCountsItemEntry]
|
||||
|
||||
init(_ view: MutableUnreadMessageCountsView) {
|
||||
self.entries = view.entries.map { entry in
|
||||
|
||||
@@ -10,14 +10,14 @@ public enum PostboxViewKey: Hashable {
|
||||
case accessChallengeData
|
||||
case preferences(keys: Set<ValueBoxKey>)
|
||||
case globalMessageTags(globalTag: GlobalMessageTags, position: MessageIndex, count: Int, groupingPredicate: ((Message, Message) -> Bool)?)
|
||||
case peer(peerId: PeerId)
|
||||
case peer(peerId: PeerId, components: PeerViewComponents)
|
||||
case pendingMessageActions(type: PendingMessageActionType)
|
||||
case invalidatedMessageHistoryTagSummaries(tagMask: MessageTags, namespace: MessageId.Namespace)
|
||||
case pendingMessageActionsSummary(type: PendingMessageActionType, peerId: PeerId, namespace: MessageId.Namespace)
|
||||
case historyTagSummaryView(tag: MessageTags, peerId: PeerId, namespace: MessageId.Namespace)
|
||||
case cachedPeerData(peerId: PeerId)
|
||||
case unreadCounts(items: [UnreadMessageCountsItem])
|
||||
case peerNotificationSettings(peerId: PeerId)
|
||||
case peerNotificationSettings(peerIds: Set<PeerId>)
|
||||
case pendingPeerNotificationSettings
|
||||
case messageOfInterestHole(location: MessageOfInterestViewLocation, namespace: MessageId.Namespace, count: Int)
|
||||
case chatListTopPeers(groupId: PeerGroupId)
|
||||
@@ -48,7 +48,7 @@ public enum PostboxViewKey: Hashable {
|
||||
return 3
|
||||
case .globalMessageTags:
|
||||
return 4
|
||||
case let .peer(peerId):
|
||||
case let .peer(peerId, _):
|
||||
return peerId.hashValue
|
||||
case let .pendingMessageActions(type):
|
||||
return type.hashValue
|
||||
@@ -62,8 +62,8 @@ public enum PostboxViewKey: Hashable {
|
||||
return peerId.hashValue
|
||||
case .unreadCounts:
|
||||
return 5
|
||||
case let .peerNotificationSettings(peerId):
|
||||
return 6 &+ 31 &* peerId.hashValue
|
||||
case let .peerNotificationSettings(peerIds):
|
||||
return 6
|
||||
case .pendingPeerNotificationSettings:
|
||||
return 7
|
||||
case let .messageOfInterestHole(location, namespace, count):
|
||||
@@ -141,8 +141,8 @@ public enum PostboxViewKey: Hashable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .peer(peerId):
|
||||
if case .peer(peerId) = rhs {
|
||||
case let .peer(peerId, components):
|
||||
if case .peer(peerId, components) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -183,8 +183,8 @@ public enum PostboxViewKey: Hashable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .peerNotificationSettings(peerId):
|
||||
if case .peerNotificationSettings(peerId) = rhs {
|
||||
case let .peerNotificationSettings(peerIds):
|
||||
if case .peerNotificationSettings(peerIds) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -267,8 +267,8 @@ func postboxViewForKey(postbox: Postbox, key: PostboxViewKey) -> MutablePostboxV
|
||||
return MutablePreferencesView(postbox: postbox, keys: keys)
|
||||
case let .globalMessageTags(globalTag, position, count, groupingPredicate):
|
||||
return MutableGlobalMessageTagsView(postbox: postbox, globalTag: globalTag, position: position, count: count, groupingPredicate: groupingPredicate)
|
||||
case let .peer(peerId):
|
||||
return MutablePeerView(postbox: postbox, peerId: peerId)
|
||||
case let .peer(peerId, components):
|
||||
return MutablePeerView(postbox: postbox, peerId: peerId, components: components)
|
||||
case let .pendingMessageActions(type):
|
||||
return MutablePendingMessageActionsView(postbox: postbox, type: type)
|
||||
case let .invalidatedMessageHistoryTagSummaries(tagMask, namespace):
|
||||
@@ -281,8 +281,8 @@ func postboxViewForKey(postbox: Postbox, key: PostboxViewKey) -> MutablePostboxV
|
||||
return MutableCachedPeerDataView(postbox: postbox, peerId: peerId)
|
||||
case let .unreadCounts(items):
|
||||
return MutableUnreadMessageCountsView(postbox: postbox, items: items)
|
||||
case let .peerNotificationSettings(peerId):
|
||||
return MutablePeerNotificationSettingsView(postbox: postbox, peerId: peerId)
|
||||
case let .peerNotificationSettings(peerIds):
|
||||
return MutablePeerNotificationSettingsView(postbox: postbox, peerIds: peerIds)
|
||||
case .pendingPeerNotificationSettings:
|
||||
return MutablePendingPeerNotificationSettingsView(postbox: postbox)
|
||||
case let .messageOfInterestHole(location, namespace, count):
|
||||
|
||||
Reference in New Issue
Block a user