mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Refactoring
This commit is contained in:
@@ -4,7 +4,7 @@ enum OrderedItemListOperation {
|
||||
case replace([OrderedItemListEntry])
|
||||
case addOrMoveToFirstPosition(OrderedItemListEntry, Int?)
|
||||
case remove(MemoryBuffer)
|
||||
case update(MemoryBuffer, OrderedItemListEntryContents)
|
||||
case update(MemoryBuffer, CodableEntry)
|
||||
}
|
||||
|
||||
private enum OrderedItemListKeyNamespace: UInt8 {
|
||||
@@ -97,7 +97,7 @@ final class OrderedItemListTable: Table {
|
||||
}, limit: 0)
|
||||
var items: [OrderedItemListEntry] = []
|
||||
for id in currentIds {
|
||||
if let contents = self.indexTable.get(collectionId: collectionId, id: id) as? OrderedItemListEntryContents {
|
||||
if let contents = self.indexTable.get(collectionId: collectionId, id: id) {
|
||||
items.append(OrderedItemListEntry(id: id, contents: contents))
|
||||
} else {
|
||||
assertionFailure()
|
||||
@@ -107,15 +107,15 @@ final class OrderedItemListTable: Table {
|
||||
}
|
||||
|
||||
func getItem(collectionId: Int32, itemId: MemoryBuffer) -> OrderedItemListEntry? {
|
||||
if let contents = self.indexTable.get(collectionId: collectionId, id: itemId) as? OrderedItemListEntryContents {
|
||||
if let contents = self.indexTable.get(collectionId: collectionId, id: itemId) {
|
||||
return OrderedItemListEntry(id: itemId, contents: contents)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func updateItem(collectionId: Int32, itemId: MemoryBuffer, item: OrderedItemListEntryContents, operations: inout [Int32: [OrderedItemListOperation]]) {
|
||||
if let _ = self.indexTable.get(collectionId: collectionId, id: itemId) as? OrderedItemListEntryContents {
|
||||
func updateItem(collectionId: Int32, itemId: MemoryBuffer, item: CodableEntry, operations: inout [Int32: [OrderedItemListOperation]]) {
|
||||
if let _ = self.indexTable.get(collectionId: collectionId, id: itemId) {
|
||||
self.indexTable.set(collectionId: collectionId, id: itemId, content: item)
|
||||
if operations[collectionId] == nil {
|
||||
operations[collectionId] = []
|
||||
|
||||
Reference in New Issue
Block a user