mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Stories
This commit is contained in:
@@ -335,7 +335,7 @@ public final class EngineStoryViewListContext {
|
||||
mediaAreas: item.mediaAreas,
|
||||
text: item.text,
|
||||
entities: item.entities,
|
||||
views: Stories.Item.Views(seenCount: Int(count), reactedCount: Int(reactionsCount), seenPeerIds: currentViews.seenPeerIds),
|
||||
views: Stories.Item.Views(seenCount: Int(count), reactedCount: Int(reactionsCount), seenPeerIds: currentViews.seenPeerIds, hasList: currentViews.hasList),
|
||||
privacy: item.privacy,
|
||||
isPinned: item.isPinned,
|
||||
isExpired: item.isExpired,
|
||||
@@ -364,7 +364,7 @@ public final class EngineStoryViewListContext {
|
||||
mediaAreas: item.mediaAreas,
|
||||
text: item.text,
|
||||
entities: item.entities,
|
||||
views: Stories.Item.Views(seenCount: Int(count), reactedCount: Int(reactionsCount), seenPeerIds: currentViews.seenPeerIds),
|
||||
views: Stories.Item.Views(seenCount: Int(count), reactedCount: Int(reactionsCount), seenPeerIds: currentViews.seenPeerIds, hasList: currentViews.hasList),
|
||||
privacy: item.privacy,
|
||||
isPinned: item.isPinned,
|
||||
isExpired: item.isExpired,
|
||||
|
||||
@@ -43,16 +43,19 @@ public enum Stories {
|
||||
case seenCount = "seenCount"
|
||||
case reactedCount = "reactedCount"
|
||||
case seenPeerIds = "seenPeerIds"
|
||||
case hasList = "hasList"
|
||||
}
|
||||
|
||||
public var seenCount: Int
|
||||
public var reactedCount: Int
|
||||
public var seenPeerIds: [PeerId]
|
||||
public var hasList: Bool
|
||||
|
||||
public init(seenCount: Int, reactedCount: Int, seenPeerIds: [PeerId]) {
|
||||
public init(seenCount: Int, reactedCount: Int, seenPeerIds: [PeerId], hasList: Bool) {
|
||||
self.seenCount = seenCount
|
||||
self.reactedCount = reactedCount
|
||||
self.seenPeerIds = seenPeerIds
|
||||
self.hasList = hasList
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@@ -61,6 +64,7 @@ public enum Stories {
|
||||
self.seenCount = Int(try container.decode(Int32.self, forKey: .seenCount))
|
||||
self.reactedCount = Int(try container.decodeIfPresent(Int32.self, forKey: .reactedCount) ?? 0)
|
||||
self.seenPeerIds = try container.decode([Int64].self, forKey: .seenPeerIds).map(PeerId.init)
|
||||
self.hasList = try container.decodeIfPresent(Bool.self, forKey: .hasList) ?? true
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@@ -69,6 +73,7 @@ public enum Stories {
|
||||
try container.encode(Int32(clamping: self.seenCount), forKey: .seenCount)
|
||||
try container.encode(Int32(clamping: self.reactedCount), forKey: .reactedCount)
|
||||
try container.encode(self.seenPeerIds.map { $0.toInt64() }, forKey: .seenPeerIds)
|
||||
try container.encode(self.hasList, forKey: .hasList)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,12 +1400,13 @@ extension Api.StoryItem {
|
||||
extension Stories.Item.Views {
|
||||
init(apiViews: Api.StoryViews) {
|
||||
switch apiViews {
|
||||
case let .storyViews(_, viewsCount, reactionsCount, recentViewers):
|
||||
case let .storyViews(flags, viewsCount, reactionsCount, recentViewers):
|
||||
let hasList = (flags & (1 << 1)) != 0
|
||||
var seenPeerIds: [PeerId] = []
|
||||
if let recentViewers = recentViewers {
|
||||
seenPeerIds = recentViewers.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }
|
||||
}
|
||||
self.init(seenCount: Int(viewsCount), reactedCount: Int(reactionsCount), seenPeerIds: seenPeerIds)
|
||||
self.init(seenCount: Int(viewsCount), reactedCount: Int(reactionsCount), seenPeerIds: seenPeerIds, hasList: hasList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ public final class EngineStoryItem: Equatable {
|
||||
public let seenCount: Int
|
||||
public let reactedCount: Int
|
||||
public let seenPeers: [EnginePeer]
|
||||
public let hasList: Bool
|
||||
|
||||
public init(seenCount: Int, reactedCount: Int, seenPeers: [EnginePeer]) {
|
||||
public init(seenCount: Int, reactedCount: Int, seenPeers: [EnginePeer], hasList: Bool) {
|
||||
self.seenCount = seenCount
|
||||
self.reactedCount = reactedCount
|
||||
self.seenPeers = seenPeers
|
||||
self.hasList = hasList
|
||||
}
|
||||
|
||||
public static func ==(lhs: Views, rhs: Views) -> Bool {
|
||||
@@ -32,6 +34,9 @@ public final class EngineStoryItem: Equatable {
|
||||
if lhs.seenPeers != rhs.seenPeers {
|
||||
return false
|
||||
}
|
||||
if lhs.hasList != rhs.hasList {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -154,7 +159,8 @@ extension EngineStoryItem {
|
||||
return Stories.Item.Views(
|
||||
seenCount: views.seenCount,
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeerIds: views.seenPeers.map(\.id)
|
||||
seenPeerIds: views.seenPeers.map(\.id),
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: self.privacy.flatMap { privacy in
|
||||
@@ -529,7 +535,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return transaction.getPeer(id).flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -656,7 +663,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return transaction.getPeer(id).flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -807,7 +815,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return peers[id].flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -849,7 +858,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return peers[id].flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -893,7 +903,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return peers[id].flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -933,7 +944,8 @@ public final class PeerStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return peers[id].flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
@@ -1097,7 +1109,8 @@ public final class PeerExpiringStoryListContext {
|
||||
reactedCount: views.reactedCount,
|
||||
seenPeers: views.seenPeerIds.compactMap { id -> EnginePeer? in
|
||||
return transaction.getPeer(id).flatMap(EnginePeer.init)
|
||||
}
|
||||
},
|
||||
hasList: views.hasList
|
||||
)
|
||||
},
|
||||
privacy: item.privacy.flatMap(EngineStoryPrivacy.init),
|
||||
|
||||
Reference in New Issue
Block a user