Swiftgram/submodules/TelegramUI/Sources/ChatHistoryNavigationStack.swift
Peter Iakovlev e9a4a9347a Revert "Rename directories [skip ci]"
This reverts commit 789438a27450dcbdee6065ebf096198ed3b90fec
2020-03-01 10:06:51 +00:00

31 lines
754 B
Swift

import Foundation
import UIKit
import Postbox
struct ChatHistoryNavigationStack {
private var messageIndices: [MessageIndex] = []
mutating func add(_ index: MessageIndex) {
self.messageIndices.append(index)
}
mutating func removeLast() -> MessageIndex? {
if messageIndices.isEmpty {
return nil
}
return messageIndices.removeLast()
}
var isEmpty: Bool {
return self.messageIndices.isEmpty
}
mutating func filterOutIndicesLessThan(_ index: MessageIndex) {
for i in (0 ..< self.messageIndices.count).reversed() {
if self.messageIndices[i] <= index {
self.messageIndices.remove(at: i)
}
}
}
}