mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Guard against large visible room list ranges
This commit is contained in:
committed by
Stefan Ceriu
parent
2ccf9de9b8
commit
5f55796b7f
@@ -49,6 +49,7 @@ enum ClientProxyError: Error {
|
|||||||
|
|
||||||
enum SlidingSyncConstants {
|
enum SlidingSyncConstants {
|
||||||
static let defaultTimelineLimit: UInt = 20
|
static let defaultTimelineLimit: UInt = 20
|
||||||
|
static let maximumVisibleRangeSize = 30
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This struct represents the configuration that we are using to register the application through Pusher to Sygnal
|
/// This struct represents the configuration that we are using to register the application through Pusher to Sygnal
|
||||||
|
|||||||
@@ -108,8 +108,16 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
|||||||
func updateVisibleRange(_ range: Range<Int>) {
|
func updateVisibleRange(_ range: Range<Int>) {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
MXLog.info("\(name): Setting visible range to \(range)")
|
// The scroll view content size based visible range calculations might create large ranges
|
||||||
try await roomListService.applyInput(input: .viewport(ranges: [.init(start: UInt32(range.lowerBound), endInclusive: UInt32(range.upperBound))]))
|
// This is just a safety check to not overload the backend
|
||||||
|
var upperBound = range.upperBound
|
||||||
|
if range.upperBound - range.lowerBound > SlidingSyncConstants.maximumVisibleRangeSize {
|
||||||
|
upperBound = range.lowerBound + SlidingSyncConstants.maximumVisibleRangeSize
|
||||||
|
}
|
||||||
|
|
||||||
|
MXLog.info("\(name): Setting visible range to \(range.lowerBound)...\(upperBound)")
|
||||||
|
|
||||||
|
try await roomListService.applyInput(input: .viewport(ranges: [.init(start: UInt32(range.lowerBound), endInclusive: UInt32(upperBound))]))
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed updating visible range with error: \(error)")
|
MXLog.error("Failed updating visible range with error: \(error)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user