Merge branch 'master' into experimental-2

This commit is contained in:
Ali
2020-09-01 22:30:17 +01:00
3 changed files with 16 additions and 7 deletions

View File

@@ -72,15 +72,21 @@ final class MutableItemCollectionInfosView: MutablePostboxView {
} }
self.entriesByNamespace = entriesByNamespace self.entriesByNamespace = entriesByNamespace
} else if !reloadTopItemCollectionIds.isEmpty { } else if !reloadTopItemCollectionIds.isEmpty {
var entriesByNamespace = self.entriesByNamespace
for (namespace, entries) in self.entriesByNamespace { for (namespace, entries) in self.entriesByNamespace {
var items: [ItemCollectionInfoEntry] = []
for i in 0 ..< entries.count { for i in 0 ..< entries.count {
if reloadTopItemCollectionIds.contains(entries[i].id) { if reloadTopItemCollectionIds.contains(entries[i].id) {
updated = true updated = true
let firstItem = postbox.itemCollectionItemTable.higherItems(collectionId: entries[i].id, itemIndex: ItemCollectionItemIndex.lowerBound, count: 1).first let firstItem = postbox.itemCollectionItemTable.higherItems(collectionId: entries[i].id, itemIndex: ItemCollectionItemIndex.lowerBound, count: 1).first
self.entriesByNamespace[namespace]![i] = ItemCollectionInfoEntry(id: entries[i].id, info: entries[i].info, count: postbox.itemCollectionItemTable.itemCount(collectionId: entries[i].id), firstItem: firstItem) items.append(ItemCollectionInfoEntry(id: entries[i].id, info: entries[i].info, count: postbox.itemCollectionItemTable.itemCount(collectionId: entries[i].id), firstItem: firstItem))
} else {
items.append(entriesByNamespace[namespace]![i])
} }
} }
entriesByNamespace[namespace] = items
} }
self.entriesByNamespace = entriesByNamespace
} }
return updated return updated
} }
@@ -88,6 +94,8 @@ final class MutableItemCollectionInfosView: MutablePostboxView {
func immutableView() -> PostboxView { func immutableView() -> PostboxView {
return ItemCollectionInfosView(self) return ItemCollectionInfosView(self)
} }
} }
public final class ItemCollectionInfosView: PostboxView { public final class ItemCollectionInfosView: PostboxView {

View File

@@ -270,7 +270,7 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q
} }
} }
|> mapToSignal { (nextRate, lowerBound, inputPeer) in |> mapToSignal { (nextRate, lowerBound, inputPeer) in
return account.network.request(Api.functions.messages.searchGlobal(flags: 0, folderId: nil, q: query, filter: filter, offsetRate: nextRate, offsetPeer: inputPeer, offsetId: lowerBound?.id.id ?? 0, limit: limit), automaticFloodWait: false) return account.network.request(Api.functions.messages.searchGlobal(flags: 0, folderId: nil, q: query, filter: .inputMessagesFilterEmpty, offsetRate: nextRate, offsetPeer: inputPeer, offsetId: lowerBound?.id.id ?? 0, limit: limit), automaticFloodWait: false)
|> map { result -> (Api.messages.Messages?, Api.messages.Messages?) in |> map { result -> (Api.messages.Messages?, Api.messages.Messages?) in
return (result, nil) return (result, nil)
} }
@@ -293,12 +293,13 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q
return (inputChannel, 0, lowerBound, .inputPeerEmpty) return (inputChannel, 0, lowerBound, .inputPeerEmpty)
} }
} }
|> mapToSignal { (inputChannel, nextRate, lowerBound, inputPeer) in |> mapToSignal { (inputChannel, nextRate, lowerBound, inputPeer) -> Signal<(Api.messages.Messages?, Api.messages.Messages?), NoError> in
guard let inputChannel = inputChannel else { guard let inputChannel = inputChannel else {
return .complete() return .complete()
} }
return .single((nil, nil))
let request = Api.functions.stats.getMessagePublicForwards(channel: inputChannel, msgId: messageId.id, offsetRate: nextRate, offsetPeer: inputPeer, offsetId: lowerBound?.id.id ?? 0, limit: limit) /*let request = Api.functions.stats.getMessagePublicForwards(channel: inputChannel, msgId: messageId.id, offsetRate: nextRate, offsetPeer: inputPeer, offsetId: lowerBound?.id.id ?? 0, limit: limit)
let signal: Signal<Api.messages.Messages, MTRpcError> let signal: Signal<Api.messages.Messages, MTRpcError>
if let datacenterId = datacenterId, account.network.datacenterId != datacenterId { if let datacenterId = datacenterId, account.network.datacenterId != datacenterId {
signal = account.network.download(datacenterId: datacenterId, isMedia: false, tag: nil) signal = account.network.download(datacenterId: datacenterId, isMedia: false, tag: nil)
@@ -315,7 +316,7 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q
} }
|> `catch` { _ -> Signal<(Api.messages.Messages?, Api.messages.Messages?), NoError> in |> `catch` { _ -> Signal<(Api.messages.Messages?, Api.messages.Messages?), NoError> in
return .single((nil, nil)) return .single((nil, nil))
} }*/
} }
} }

View File

@@ -534,9 +534,9 @@ extension StoreMessage {
attributes.append(ViewCountMessageAttribute(count: Int(views))) attributes.append(ViewCountMessageAttribute(count: Int(views)))
} }
if let forwards = forwards { /*if let forwards = forwards {
attributes.append(ForwardCountMessageAttribute(count: Int(forwards))) attributes.append(ForwardCountMessageAttribute(count: Int(forwards)))
} }*/
} }
if let editDate = editDate { if let editDate = editDate {